10% work
complete most xml relax ng work. work on real interface xml work on python scripts for parsing interface xml
This commit is contained in:
54
python/mine/ri_tk.py
Normal file
54
python/mine/ri_tk.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
''' handle display related work upon Tkinter '''
|
||||
|
||||
import Tkinter
|
||||
|
||||
def initialize(base_w):
|
||||
''' base widget xml node '''
|
||||
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()
|
||||
Reference in New Issue
Block a user