-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commands.py
66 lines (58 loc) · 2.21 KB
/
Commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"tkinter widget event handler methods"
import tkinter as tk
from tkinter import messagebox
class Commands:
"Event handler methods"
@staticmethod
def print_piles(root, cg):
"Display string array of card piles"
root.wp_label["text"]= cg.pileMap['work'].print_cards()
root.fp_label["text"]= cg.pileMap['leisure'].print_cards()
root.dp_label["text"]= cg.pileMap['discard'].print_cards()
@staticmethod
def draw(root, cg):
"Draw a card"
cg.draw()
Commands.print_piles(root, cg)
Commands.set_sum_times(root, cg)
@staticmethod
def discard_pile(root, cg):
"Add pile to discard pile"
pile = root.atd_om_var.get().lower()
cg.pileMap[pile].add_to_discard(cg.pileMap['discard'])
Commands.print_piles(root,cg)
Commands.set_sum_times(root, cg)
@staticmethod
def draw_to_target(root, cg):
"Draw to target value"
target_time = 0
try:
if(root.dtt_tb.get() != ""):
target_time = int(root.dtt_tb.get())
except ValueError:
tk.messagebox.showinfo(message="Value must be an integer")
pile = root.dtt_om_var.get().lower()
pile = cg.pileMap[pile]
cg.draw_to_pile_target(pile, target_time, target_time)
Commands.print_piles(root,cg)
Commands.set_sum_times(root, cg)
@staticmethod
def remove_to_target(root, cg):
"Remove to target value"
target_time = 0
try:
if(root.rft_tb.get() != ""):
target_time = int(root.rft_tb.get())
except ValueError:
tk.messagebox.showinfo(message="Value must be an integer")
pile = root.rbt_om_var.get().lower()
pile = cg.pileMap[pile]
cg.remove_to_pile_target(pile, target_time, root)
Commands.print_piles(root,cg)
Commands.set_sum_times(root,cg)
@staticmethod
def set_sum_times(root, cg):
"Displays sum total time for each pile"
root.wp_l["text"] = "Sum: " + cg.pileMap['work'].print_sum_value
root.fp_l["text"] = "Sum: " + cg.pileMap['leisure'].print_sum_value
root.dp_l["text"] = "Sum: " + cg.pileMap['discard'].print_sum_value