67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
#!/usr/bin/python
|
|
''' handle display related work upon Tkinter '''
|
|
|
|
import Tkinter
|
|
import tkMessageBox
|
|
def initialize(base_w):
|
|
''' base_w - base widget instance '''
|
|
global root_window
|
|
root_window = Tkinter.Tk()
|
|
|
|
# grid management for root_window
|
|
root_window.columnconfigure(0, weight=1)
|
|
root_window.rowconfigure(0, weight=1)
|
|
root_window.geometry("%sx%s+0+0" %(root_window.winfo_screenwidth(),root_window.winfo_screenheight()))
|
|
|
|
global base_widget
|
|
base_widget = display_widget_sub(base_w, root_window)
|
|
|
|
def quit():
|
|
''' exit root window '''
|
|
root_window.quit()
|
|
|
|
def display_widget(w):
|
|
''' w - widget instance '''
|
|
global current_window
|
|
current_window = display_widget_sub(w, base_widget)
|
|
|
|
def display_widget_sub(w, p_win):
|
|
'''
|
|
w - widget instance
|
|
p_win - Tk parent window '''
|
|
tk_func = getattr(Tkinter, w.tp)
|
|
w_win = tk_func(p_win, w.attr)
|
|
|
|
# display sub widgets
|
|
if 'widgets' in dir(w):
|
|
for sub_w in w.widgets:
|
|
display_widget_sub(sub_w, w_win)
|
|
|
|
# grid management
|
|
if 'grid_management' in dir(w):
|
|
for cf in w.grid_management.cf_list:
|
|
cf_func = getattr(w_win, cf[0])
|
|
cf_func( cf[1], weight=cf[2])
|
|
|
|
# grid location
|
|
if 'grid_location' in dir(w):
|
|
w_win.grid(w.grid_location.dict)
|
|
|
|
return w_win
|
|
|
|
def kill_widget(win):
|
|
''' win - Tk window instance '''
|
|
win.destroy()
|
|
|
|
#def display_entry(w):
|
|
|
|
#def display_listbox(w):
|
|
|
|
#def display_radiobutton(w):
|
|
|
|
def display_message_box(w):
|
|
''' display MessageBox
|
|
w - widget instance'''
|
|
disp = getattr(tkMessageBox, "show%s" %(w.tp))
|
|
disp(w.title, w.message)
|