Created
April 18, 2014 18:55
-
-
Save Nagasaki45/11059110 to your computer and use it in GitHub Desktop.
Bursa GUI module for the simcity project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Tkinter import * | |
class StocksGuiBuilder(object): | |
class Stock(object): | |
MODES = ('Up', 'Down', 'Unchanged') | |
def __init__(self, parent): | |
Label(parent, text='Stock name').pack(side=LEFT) | |
self.name = StringVar() | |
Entry(parent, textvariable=self.name).pack(side=LEFT) | |
Label(parent, text='Stock value').pack(side=LEFT) | |
self.value = StringVar() | |
Entry(parent, textvariable=self.value).pack(side=LEFT) | |
self.direction = StringVar() | |
for m in self.MODES: | |
rb = Radiobutton(parent, text=m, | |
variable=self.direction, value=m) | |
rb.pack(side=LEFT) | |
def __str__(self): | |
return '{} - {}$ ({})'.format(self.name.get(), | |
self.value.get(), | |
self.direction.get()) | |
def __init__(self, num_of_stocks=4): | |
win = Tk() | |
self.stocks = [] | |
for _ in xrange(num_of_stocks): | |
f = Frame(win) | |
self.stocks.append(self.Stock(f)) | |
f.pack() | |
get_stock_as_string_button = Button(win, | |
text='get_stocks', | |
command=self.printer) | |
get_stock_as_string_button.pack() | |
def printer(self): | |
print(str(self)) | |
def __str__(self): | |
return ' ... '.join(str(s) for s in self.stocks) | |
s = StocksGuiBuilder() | |
mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment