Skip to content

Commit

Permalink
Add adjust button
Browse files Browse the repository at this point in the history
  • Loading branch information
vdumoulin committed Dec 29, 2014
1 parent b7dd4a4 commit 21e0f78
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ def clear_order(self):
finally:
self.update_order()

def adjust(self, token):
try:
amount = float(token)
self.register.adjust(amount)
except CredentialException:
self.logger.warning("insufficient privileges to adjust register " +
"count")
except ValueError as e:
self.logger.warning("invalid adjustment amount: " + e)
def adjust(self):
amount = askfloat(title="Enter adjustment amount",
prompt="Adjustment amount")
if amount is not None:
try:
self.register.adjust(amount)
except CredentialException:
self.logger.warning("insufficient privileges to adjust " +
"register count")
except ValueError as e:
self.logger.warning("invalid adjustment amount: " + e)

def checkout(self):
try:
Expand All @@ -112,6 +114,7 @@ def checkout(self):
self.logger.warning("insufficient privileges to checkout order")

def count(self):
# TODO: implement a proper register count
count = askfloat(title="Enter register count", prompt="Register count")
if count is not None:
try:
Expand Down Expand Up @@ -207,14 +210,13 @@ def init_ui(self):
self.logout_button = Button(self, text="Logout",
command=self.logout)
self.logout_button.grid(row=1, column=1, columnspan=2, sticky=(E, W))
# private JButton countButton;
self.count_button = Button(self, text="Count register",
command=self.count)
self.count_button.grid(row=2, column=1, columnspan=2, sticky=(E, W))
# private JButton ajustementButton;
# self.logout_button = Button(self, text="Logout",
# command=self.logout)
# self.logout_button.grid(row=1, column=1, columnspan=2, sticky=(E, W))
self.adjust_button = Button(self, text="Register adjustment",
command=self.adjust)
self.adjust_button.grid(row=3, column=1, columnspan=2, sticky=(E, W))
# private JButton montantArbButton;
# self.logout_button = Button(self, text="Logout",
# command=self.logout)
Expand Down

0 comments on commit 21e0f78

Please sign in to comment.