def updates_get(ui, gridname, ignoreaxes=False): maxx = maxy = -1 if ignoreaxes == True: maxx = maxy = 0 update_keys = [[gridname, update.split(",")[1], update.split(",")[2]] for update in ui.updates.keys() if update.split(",")[0] == gridname if int(update.split(",")[1]) > maxx if int(update.split(",")[2]) > maxy] if len(update_keys) == 0: log.log(thisfuncname(), 3, msg="updates requested but none found", gridname=gridname) #raise Exception("no updates registered for",gridname) else: if ignoreaxes == False: offset = 1 else: offset = 0 xsize = max([int(key[1]) for key in update_keys]) + offset ysize = max([int(key[2]) for key in update_keys]) + offset # text values of widgets values = nxnarraycreate(int(xsize), int(ysize), "") for key in update_keys: if ignoreaxes == False: offset = 0 else: offset = -1 values[int(key[1]) + offset][int(key[2]) + offset] = ui.updates[str( ",".join(key))] # background color of widgets bgcolor = nxnarraycreate(int(xsize), int(ysize), "") for key in update_keys: grid = getattr(ui, gridname) #_color = self.balancegrid.widgets[int(key[1])][int(key[2])].cget('background') _color = grid.widgets[int(key[1])][int(key[2])].cget('background') bgcolor[int(key[1]) - 1][int(key[2]) - 1] = _color return values, bgcolor return 0, 0
def __init__(self, database): Tk.__init__(self) self.maxrows = 9 # rows in the grid self.maxcols = 10 # cols in the grid maxwidgets = self.maxrows * self.maxcols wwidth = 48 # default button width with text of 3 chars wheight = 29 # default button height wmheight = wheight * 20 # master height wmwidth = wwidth * 20 # master width geom = geometry_get(wmheight, wmwidth, 0, 0) self.geometry(geom) widget_args = dict(background='white') widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) widgetcfg = dropdown_build(database, widgetcfg, _execfunc, _rowheaderexecfunc, _columnheaderexecfunc) setmemberp = SetMemberPartial(name='x{mylist}', set=[]) self.entrygrid = TkImageLabelGrid(self, 'entrygrid', setmemberp, wmwidth, wmheight, 0, 0, self.maxrows, self.maxcols, {}, widgetcfg) self.entrygrid.grid(row=0, sticky=NSEW)
def __init__(self,database): Tk.__init__(self) self.maxrows=9 # rows in the grid self.maxcols=10 # cols in the grid maxwidgets=self.maxrows*self.maxcols wwidth=48 # default button width with text of 3 chars wheight=29 # default button height wmheight=wheight*20 # master height wmwidth=wwidth*20 # master width geom = geometry_get(wmheight,wmwidth,0,0) self.geometry(geom) widget_args=dict(background='white') widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) widgetcfg = dropdown_build(database,widgetcfg, _execfunc, _rowheaderexecfunc, _columnheaderexecfunc) setmemberp = SetMemberPartial(name='x{mylist}',set=[]) self.entrygrid = TkImageLabelGrid(self,'entrygrid',setmemberp,wmwidth,wmheight, 0,0,self.maxrows,self.maxcols, {},widgetcfg) self.entrygrid.grid(row=0,sticky=NSEW)
def __init__(self): Tk.__init__(self) self.maxrows=10 # rows in the grid self.maxcols=10 # cols in the grid self.maxwidgets=self.maxrows*self.maxcols self.wwidth=48 # default button width with text of 3 chars self.wheight=29 # default button height self.wmheight=self.wheight*self.maxrows # master height self.wmwidth=self.wwidth*self.maxcols # master width members = ['pineapple','grapefruit','banana', 'peach','pomegranate','passionfruit', 'pear','grape','strawberry','raspberry', 'rhubarb','mango','guava','apple', 'Orange'] widget_args=dict(background='white',values=members) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) self.setmemberp = SetMemberPartial(name='x{mylist}',set=members) self.tkilg = TkImageLabelGrid(self.master,'grid',self.setmemberp,self.wmwidth,self.wmheight, 0,0,7,5,{},widgetcfg) self.tkilg.grid(row=0,column=0,sticky=NSEW) self.grid_rowconfigure(0, weight=1, uniform="foo") self.grid_columnconfigure(0, weight=1, uniform="foo")
def setUp(self): self.master = Tk() self.master.geometry("400x200+0+0") self.maxrows=3 # rows in the grid self.maxcols=3 # cols in the grid self.maxwidgets=self.maxrows*self.maxcols self.wwidth=48 # default button width with text of 3 chars self.wheight=29 # default button height self.wmheight=self.wheight*self.maxrows # master height self.wmwidth=self.wwidth*self.maxcols # master width #font = tkFont.Font(family="monospace", size=12) self.style = Style() self.style.theme_use("default") self.mytextalphanum = TextAlphaNum(name='textalphanum') widget_args=dict(background='white',width=9) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) self.mytextalphanum.widgettype = TkNLabel self.tkilg = TkImageLabelGrid(self.master,'grid',self.mytextalphanum, self.wmwidth,self.wmheight, 0,0,self.maxrows,self.maxcols ,True,True,{},widgetcfg) self.tkilg.grid(row=0,column=0,sticky=NSEW) self.master.grid_rowconfigure(0, weight=1, uniform="foo") self.master.grid_columnconfigure(0, weight=1, uniform="foo")
def updates_get(ui,gridname,ignoreaxes=False): maxx = maxy = -1 if ignoreaxes == True: maxx = maxy = 0 update_keys = [ [gridname,update.split(",")[1],update.split(",")[2]] for update in ui.updates.keys() if update.split(",")[0] == gridname if int(update.split(",")[1]) > maxx if int(update.split(",")[2]) > maxy] if len(update_keys)==0: log.log(thisfuncname(),3,msg="updates requested but none found",gridname=gridname) #raise Exception("no updates registered for",gridname) else: if ignoreaxes == False: offset = 1 else: offset = 0 xsize= max([int(key[1]) for key in update_keys]) + offset ysize= max([int(key[2]) for key in update_keys]) + offset # text values of widgets values = nxnarraycreate(int(xsize),int(ysize),"") for key in update_keys: if ignoreaxes == False: offset = 0 else: offset = -1 values[int(key[1])+offset][int(key[2])+offset] = ui.updates[str(",".join(key))] # background color of widgets bgcolor = nxnarraycreate(int(xsize),int(ysize),"") for key in update_keys: grid = getattr(ui,gridname) #_color = self.balancegrid.widgets[int(key[1])][int(key[2])].cget('background') _color = grid.widgets[int(key[1])][int(key[2])].cget('background') bgcolor[int(key[1])-1][int(key[2])-1] = _color return values,bgcolor return 0,0
def setUp(self): self.master = Tk() self.maxrows=2 # rows in the grid self.maxcols=2 # cols in the grid self.wmheight=400 # master height self.wmwidth=400 # master width #geom = geometry_get(self.wmheight,self.wmwidth,0,0) #self.master.geometry(geom) image_args = dict(pointsize=12,font='Helvetica',gravity='center', rotate=90,label='foobar') gridcfg = nxnarraycreate(self.maxrows,self.maxcols,image_args) widget_args={} widgetcfg = nxnarraycreate(self.maxrows,self.maxcols, widget_args) gridcfg[1][1]['rotate'] = 270 self.mytextalphanumro = TextAlphaNumRO(name='set') #self.mytextalphanumro.widgettype = TkNLabel self.tkilg = TkImageLabelGrid(self.master,'grid',self.mytextalphanumro,self.wmwidth,self.wmheight, 0,0, self.maxrows,self.maxcols, True,False, gridcfg,widgetcfg, 1) self.tkilg.grid(row=0,column=0,sticky=NSEW) self.tkilg.grid_rowconfigure(0, weight=1, uniform="foo") self.tkilg.grid_columnconfigure(0, weight=1, uniform="foo") self.tkilg.image_set()
def dropdowns_set(self): #widget_args=dict(background='red',width=9,values=self.enums['student']) widget_args=dict(background='red',width=9,values=[]) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) widgetcfg = sswizard_utils.dropdown_build(self.refdatabase,widgetcfg, _execfunc,self.prep_entry_sv.get(), self.dow_entry_sv.get(), _columnheaderexecfunc,_rowheaderexecfunc) for x in range(self.maxrows): for y in range(self.maxcols): self.entrygrid.widgets[x][y].config(**widgetcfg[x][y])
def test_col3(self): prep=5 widget_args=dict(background='white') widgetcfg = nxnarraycreate(self.maxx,self.maxy,widget_args) widgetcfg = dropdown_build(self.database,widgetcfg,_execfunc,prep) expected_results = [u'DA.AC.HU', u'BR.AC.ST', u'JA.??.SP', u'TH.AC.ST', u'JE.AC.HU'] expected_results.sort() results = widgetcfg[1][3]['values'] results.sort() self.assertEqual(results,expected_results)
def setUp(self): self.database = Database(CURRENTDIR + "/" + THISEXEC + "/" + 'test_sswizard') self.classtbl = 'class' self.maxx = 8 self.maxy = 10 widget_args = dict(background='white') self.widgetcfg = nxnarraycreate(self.maxx + 1, self.maxy + 1, widget_args) self.widgetcfg = dropdown_build(self.database, self.widgetcfg, _execfunc, 5, "MO", _rowheaderexecfunc, _columnheaderexecfunc)
def setUp(self): self.database = Database('test_sswizard_utils') self.classtbl = 'class' self.maxx = 8 self.maxy = 10 widget_args=dict(background='white') self.widgetcfg = nxnarraycreate(self.maxx+1,self.maxy+1,widget_args) self.widgetcfg = dropdown_build(self.database, self.widgetcfg, _execfunc, _rowheaderexecfunc, _columnheaderexecfunc)
def test_col2(self): prep = 5 widget_args = dict(background='white') widgetcfg = nxnarraycreate(self.maxx, self.maxy, widget_args) widgetcfg = dropdown_build(self.database, widgetcfg, _execfunc, prep, "MO") expected_results = [ u'??.??.??.MO', u'??.BK.MOVE.MO', u'??.PY.SPCH.MO', u'ALEX.??.??.MO', u'AMEL.AC.ELA.MO', u'PARC.AC.SC.MO' ] expected_results.sort() results = widgetcfg[1][2]['values'] results.sort() self.assertListEqual(results, expected_results)
def dropdowns_set(self): # make sure that the refdatabase is the same as the database self.refdatabase = Database(self.dbname_entry_sv.get()) #widget_args=dict(background='red',width=9,values=self.enums['student']) widget_args = dict(background='red', width=9, values=[]) widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) widgetcfg = sswizard_utils.dropdown_build(self.refdatabase, widgetcfg, _execfunc, self.prep_entry_sv.get(), self.dow_entry_sv.get(), _columnheaderexecfunc, _rowheaderexecfunc) for x in range(self.maxrows): for y in range(self.maxcols): _widget = self.entrygrid.widgets[x][y] _widget.config(**widgetcfg[x][y]) #setattr(_widget,"orig_values",_widget['values']) setattr(_widget, "orig_values", _widget['values'])
def viewer(self): font = tkFont.Font(family="monospace", size=12) self.viewerui = Toplevel(self.master) self.viewerui.transient(self.master) self.viewerui.geometry("2000x1000+0+0") controlpanel = Frame(self.viewerui) controlpanel.grid(row=0, column=0, sticky=NSEW) self.viewerui.xaxis_label = Label(controlpanel, text="xaxis", font=font) self.viewerui.xaxis_label.grid(row=0, column=0) self.viewerui.xaxis_label.focus_get() self.viewerui.xaxis_label_sv = StringVar() self.viewerui.xaxis_label = Entry( controlpanel, textvariable=self.viewerui.xaxis_label_sv, font=font) self.viewerui.xaxis_label.grid(row=0, column=1) self.viewerui.xaxis_label.focus_get() self.viewerui.xaxis_label_sv.set("period") self.viewerui.yaxis_label = Label(controlpanel, text="yaxis", font=font) self.viewerui.yaxis_label.grid(row=0, column=2) self.viewerui.yaxis_label.focus_get() self.viewerui.yaxis_label_sv = StringVar() self.viewerui.yaxis_label = Entry( controlpanel, textvariable=self.viewerui.yaxis_label_sv, font=font) self.viewerui.yaxis_label.grid(row=0, column=3) self.viewerui.yaxis_label.focus_get() self.viewerui.yaxis_label_sv.set("dow") self.viewerui.prep_label = Label(controlpanel, text="prep", font=font) self.viewerui.prep_label.grid(row=0, column=4) self.viewerui.prep_label.focus_get() self.viewerui.prep_label_sv = StringVar() self.viewerui.prep_label = Entry( controlpanel, textvariable=self.viewerui.prep_label_sv, font=font) self.viewerui.prep_label.grid(row=0, column=5) self.viewerui.prep_label.focus_get() self.viewerui.student_label = Label(controlpanel, text="student", font=font) self.viewerui.student_label.grid(row=0, column=6) self.viewerui.student_label.focus_get() self.viewerui.student_label_sv = StringVar() self.viewerui.student_label = Entry( controlpanel, textvariable=self.viewerui.student_label_sv, font=font) self.viewerui.student_label.grid(row=0, column=7) self.viewerui.student_label.focus_get() self.viewerui.student_label_sv.set("Nathaniel") self.viewerui.teacher_label = Label(controlpanel, text="dow", font=font) self.viewerui.teacher_label.grid(row=0, column=8) self.viewerui.teacher_label.focus_get() self.viewerui.teacher_label_sv = StringVar() self.viewerui.teacher_label = Entry( controlpanel, textvariable=self.viewerui.teacher_label_sv, font=font) self.viewerui.teacher_label.grid(row=0, column=9) self.viewerui.teacher_label.focus_get() self.recalc_button = Button(controlpanel, command=self.viewer_calc, text="calc", name="vc") self.recalc_button.grid(row=0, column=0) self.recalc_button.focus_get() values = self.viewer_calc() #self.bgmaxrows=len(self.enums['period']['name'])+1 #self.bgmaxcols=len(self.of.query('student'))+1 self.bgmaxrows = len(values) self.bgmaxcols = len(values[0]) widget_args = dict(background='white', width=2, height=3, wraplength=180, highlightbackground='black', highlightthickness=4, font=font, values=self.enums['dow']) widgetcfg = nxnarraycreate(self.bgmaxrows, self.bgmaxcols, widget_args) mytextalphanum = TextAlphaNumRO(name='textalphanum') try: self.viewergrid.destroy() except: pass self.viewergrid = TkImageLabelGrid(self.viewerui, 'viewergrid', mytextalphanum, 10, 10, 0, 0, self.bgmaxrows, self.bgmaxcols, True, False, {}, widgetcfg) self.viewergrid.grid(row=1, column=0, sticky=NSEW) self.viewerui.grid_rowconfigure(1, weight=1, uniform="foo") self.viewerui.grid_columnconfigure(0, weight=1, uniform="foo") for x in range(len(values)): for y in range(len(values[x])): self.viewergrid.widgets[x][y].sv.set(values[x][y])
def viewer(self, ui=True, source_type=None, source_value=None, ztypes=None, yaxis_type=None, xaxis_type=None, conflicts_only=None, constraints=None, wratio=None, formatson=False, valuetype=False): # constraint will be a list of tuples of the form # objtype,objvalue i.e. ('dow','MO') if conflicts_only == None: conflicts_only = self.conflict_checkbutton_sv.get() if yaxis_type == None: yaxis_type = self.viewyaxis_label_sv.get() # dow if xaxis_type == None: xaxis_type = self.viewxaxis_label_sv.get() # period if source_type == None or source_value == None: source_type, source_value = self.viewfocus_label_sv.get().split( "=") if wratio == None: wratio = self.wratio_label_sv.get().split(",") # what attributes of an object do we want to display # if * is passed that means show the count of the number of records returned if ztypes == None: ztypes = self.viewdata_label_sv.get().split(",") values = ssviewer_utils.dataset_pivot(self.of, self.enums, yaxis_type, xaxis_type, ztypes, source_type, source_value, conflicts_only, constraints, wratio, formatson) if ui == True: self.bgmaxrows = len(values) self.bgmaxcols = len(values[0]) #,wraplength=240 widget_args = dict(background='white', width=1, height=4, highlightbackground='black', highlightthickness=1, values=self.enums['dow']) widgetcfg = nxnarraycreate(self.bgmaxrows, self.bgmaxcols, widget_args) mytextalphanum = TextAlphaNumRO(name='textalphanum') try: self.viewergrid.destroy() except: pass mytextalphanum.widgettype = TkNLabel self.viewergrid = TkImageLabelGrid(self, 'viewergrid', mytextalphanum, 10, 10, 0, 0, self.bgmaxrows, self.bgmaxcols, True, False, {}, widgetcfg, 1) self.viewergrid.grid(row=3, column=0, sticky=NSEW) self.grid_rowconfigure(3, weight=10, uniform="foo") for x in range(len(values)): for y in range(len(values[x])): widget = self.viewergrid.widgets[x][y] _value = values[x][y] if isinstance(_value, list) == True: if _value <> []: #if len(_value) == 1 and conflicts_only <> "Y": # replace with line below if want to switch on conflicts if len(_value) == 1: if isinstance(_value[0], tuple) == True: # 1 item, multi attributes bgs, fgs = ssviewer_utils._color_get_multi( _value[0]) _widgets = widget.addlabel( len(_value[0]), True, _value[0], bgs, fgs, wratio) elif isinstance(_value[0], list) == False: # 1 item, single value bg, fg = ssviewer_utils.color_get( _value[0]) _widgets = widget.addlabel( 1, True, _value[0], bg, fg) # multiple items #if len(_value) > 1 and conflicts_only == "Y": # replace with line below if want to switch on conflicts if len(_value) > 1: for __value in _value: bgs, fgs = ssviewer_utils._color_get_multi( __value) _widgets = widget.addlabel( len(__value), True, __value, bgs, fgs, wratio) else: expand = False if x == 0 or y == 0: expand = True _widgets = widget.addlabel(expand) _widgets[0].sv.set(_value) else: schema = None if valuetype == True: schema = dict(xaxis=xaxis_type, yaxis=yaxis_type, ztypes=ztypes) values = ssviewer_utils.dataset_serialize(values, formatson, schema=schema) return values self.viewergrid.reset_framewidth() self.viewergrid.resize_canvasframe()
def viewer(self): font = tkFont.Font(family="monospace", size=18) self.viewerui = Toplevel(self.master) self.viewerui.transient(self.master) self.viewerui.geometry("2000x1000+0+0") controlpanel = Frame(self.viewerui) controlpanel.grid(row=0,column=0,sticky=NSEW) self.viewerui.xaxis_label = Label(controlpanel,text="xaxis",font=font) self.viewerui.xaxis_label.grid(row=0,column=0) self.viewerui.xaxis_label.focus_get() self.viewerui.xaxis_label_sv = StringVar() self.viewerui.xaxis_label = Entry(controlpanel,textvariable=self.viewerui.xaxis_label_sv,font=font) self.viewerui.xaxis_label.grid(row=0,column=1) self.viewerui.xaxis_label.focus_get() self.viewerui.xaxis_label_sv.set("period") self.viewerui.yaxis_label = Label(controlpanel,text="yaxis",font=font) self.viewerui.yaxis_label.grid(row=0,column=2) self.viewerui.yaxis_label.focus_get() self.viewerui.yaxis_label_sv = StringVar() self.viewerui.yaxis_label = Entry(controlpanel,textvariable=self.viewerui.yaxis_label_sv,font=font) self.viewerui.yaxis_label.grid(row=0,column=3) self.viewerui.yaxis_label.focus_get() self.viewerui.yaxis_label_sv.set("dow") self.viewerui.prep_label = Label(controlpanel,text="prep",font=font) self.viewerui.prep_label.grid(row=0,column=4) self.viewerui.prep_label.focus_get() self.viewerui.prep_label_sv = StringVar() self.viewerui.prep_label = Entry(controlpanel,textvariable=self.viewerui.prep_label_sv,font=font) self.viewerui.prep_label.grid(row=0,column=5) self.viewerui.prep_label.focus_get() self.viewerui.student_label = Label(controlpanel,text="student",font=font) self.viewerui.student_label.grid(row=0,column=6) self.viewerui.student_label.focus_get() self.viewerui.student_label_sv = StringVar() self.viewerui.student_label = Entry(controlpanel,textvariable=self.viewerui.student_label_sv,font=font) self.viewerui.student_label.grid(row=0,column=7) self.viewerui.student_label.focus_get() self.viewerui.student_label_sv.set("Nathaniel") self.viewerui.teacher_label = Label(controlpanel,text="dow",font=font) self.viewerui.teacher_label.grid(row=0,column=8) self.viewerui.teacher_label.focus_get() self.viewerui.teacher_label_sv = StringVar() self.viewerui.teacher_label = Entry(controlpanel,textvariable=self.viewerui.teacher_label_sv,font=font) self.viewerui.teacher_label.grid(row=0,column=9) self.viewerui.teacher_label.focus_get() self.recalc_button = Button(controlpanel,command=self.viewer_calc,text="calc", name="vc") self.recalc_button.grid(row=0,column=0) self.recalc_button.focus_get() values = self.viewer_calc() #self.bgmaxrows=len(self.enums['period']['name'])+1 #self.bgmaxcols=len(self.of.query('student'))+1 self.bgmaxrows=len(values) self.bgmaxcols=len(values[0]) widget_args=dict(background='white',width=2,height=3,wraplength=180, highlightbackground='black',highlightthickness=4, font=font,values=self.enums['dow']) widgetcfg = nxnarraycreate(self.bgmaxrows,self.bgmaxcols,widget_args) mytextalphanum = TextAlphaNumRO(name='textalphanum') try: self.viewergrid.destroy() except: pass self.viewergrid = TkImageLabelGrid(self.viewerui,'viewergrid', mytextalphanum,10,10, 0,0,self.bgmaxrows,self.bgmaxcols, True,False,{},widgetcfg) self.viewergrid.grid(row=1,column=0,sticky=NSEW) self.viewerui.grid_rowconfigure(1, weight=1, uniform="foo") self.viewerui.grid_columnconfigure(0, weight=1, uniform="foo") for x in range(len(values)): for y in range(len(values[x])): self.viewergrid.widgets[x][y].sv.set(values[x][y])
def __init__(self,dbname,of,refdbname,maxentrycols=3,maxentryrows=4, maxnewrowcols=3,maxnewrowrows=3): log.log(thisfuncname(),3,msg="initialize",dbname=dbname,refdbname=refdbname) #self.clipboard=[] #self.clipboard_selection=-1 Tk.__init__(self) self.geometry("2000x500+0+0") self.refdatabase = Database(refdbname) #self.enums = sswizard_utils.setenums('All','5',self.refdatabase) self.dbname = dbname self.database = Database(self.dbname) self.of = of font = tkFont.Font(family="monospace", size=12) self.lastsaveversion=0 style = Style() style.theme_use("default") bigfont = tkFont.Font(family="Helvetica",size=50) self.option_add("*TCombobox*Listbox*Font", bigfont) self.current_inputmode = "Normal" set_configs(style) # any children that change update this # key is the name and value is the new val # the name is likely to be the tkwidgetid.x,y self.updates = OrderedDict() self.maxrows=maxentryrows # rows in the grid self.maxcols=maxentrycols # cols in the grid maxwidgets=self.maxrows*self.maxcols wwidth=48 # default button width with text of 3 chars wheight=29 # default button height wmheight=wheight*self.maxrows # master height wmwidth=wwidth*self.maxcols # master width #geom = geometry_get(1000,1000,0,0) #self.geometry(geom) self.bind("<Prior>",self.focus_next_widget) # daygrids setmemberp = SetMemberPartial(name='x{mylist}',set=['Monday']) widget_args=dict(background='white',width=9,font=font,values=['Monday']) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) # daygrid 1 self.dowentrygrid = TkImageLabelGrid(self,'dowentrygrid',setmemberp,wmwidth,wmheight,0,0,1,self.maxcols,True,{},widgetcfg) self.dowentrygrid.grid(row=0,column=0,sticky=EW) # entrygrids setmemberp = SetMemberPartial(name='x{mylist}',set=[]) widget_args=dict(background='white',width=9,font=font,values=[]) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) # entrygrid 1 setmemberp.widgettype = TkGridCombobox self.entrygrid = TkImageLabelGrid(self,'entrygrid',setmemberp,wmwidth,wmheight,0,0,self.maxrows,self.maxcols,True,True,{},widgetcfg) self.entrygrid['style'] = 'EntryGrid.TFrame' self.entrygrid.grid(row=1,column=0,sticky=NSEW) buttonpanel = Frame(self,style='ControlPanel.TFrame') buttonpanel.grid(row=2,column=0,sticky=NSEW,columnspan=2) self.save_button = Button(buttonpanel,command=self.save,text="save",name="svb") self.save_button.grid(row=0,column=0) self.save_button.focus_get() self.persist_button = Button(buttonpanel,command=self.persist,text="persist",name="pb") self.persist_button.grid(row=0,column=1) self.persist_button.focus_get() self.dbload_button = Button(buttonpanel,command=self.load,text="dbload",name="dbl") self.dbload_button.grid(row=0,column=2) self.dbload_button.focus_get() self.clear_button = Button(buttonpanel,command=self.clear,text="clear",name="clr") self.clear_button.grid(row=0,column=3) self.clear_button.focus_get() self.viewer_button = Button(buttonpanel,command=self.viewer,text="viewer",name="view") self.viewer_button.grid(row=0,column=4) self.viewer_button.focus_get() self.rebuilddropdown_button = Button(buttonpanel,command=self.dropdowns_set,text="ddown",name="ddown") self.rebuilddropdown_button.grid(row=0,column=5) self.rebuilddropdown_button.focus_get() controlpanel = Frame(self,style='ControlPanel.TFrame') controlpanel.grid(row=3,column=0,sticky=NSEW,columnspan=2) self.dbload_entry_label = Label(controlpanel,text="version") self.dbload_entry_label.grid(row=0,column=0) self.dbload_entry_label.focus_get() self.dbload_entry_sv = StringVar() self.dbload_entry = Entry(controlpanel,textvariable=self.dbload_entry_sv) self.dbload_entry.grid(row=0,column=1) self.dbload_entry.focus_get() self.dbname_entry_label = Label(controlpanel,text="dbname") self.dbname_entry_label.grid(row=0,column=2) self.dbname_entry_label.focus_get() self.dbname_entry_sv = StringVar() self.dbname_entry = Entry(controlpanel,textvariable=self.dbname_entry_sv) self.dbname_entry.grid(row=0,column=3) self.dbname_entry.focus_get() self.dbname_entry_sv.set(self.dbname) self.dow_entry_label = Label(controlpanel,text="dow",width=10) self.dow_entry_label.grid(row=0,column=4) self.dow_entry_label.focus_get() self.dow_entry_sv = StringVar() self.dow_entry = Entry(controlpanel,textvariable=self.dow_entry_sv,width=10) self.dow_entry.grid(row=0,column=5) self.dow_entry.focus_get() self.dow_entry_sv.set('MO') self.prep_label = Label(controlpanel,text="prep",width=10) self.prep_label.grid(row=0,column=6) self.prep_label.focus_get() self.prep_entry_sv = StringVar() self.prep_entry = Entry(controlpanel,textvariable=self.prep_entry_sv,width=10) self.prep_entry.grid(row=0,column=7) self.prep_entry.focus_get() self.prep_entry_sv.set(5) self.grid_rowconfigure(0, weight=1, uniform="foo") self.grid_rowconfigure(1, weight=10, uniform="foo") self.grid_rowconfigure(2, weight=1, uniform="foo") self.grid_rowconfigure(3, weight=1, uniform="foo") self.grid_columnconfigure(0, weight=1, uniform="foo")
def viewer(self,ui=True,source_type=None,source_value=None, ztypes=None,yaxis_type=None,xaxis_type=None, conflicts_only=None,constraints=None,wratio=None,formatson=False, valuetype=False): # constraint will be a list of tuples of the form # objtype,objvalue i.e. ('dow','MO') if conflicts_only == None: conflicts_only = self.conflict_checkbutton_sv.get() if yaxis_type == None: yaxis_type = self.viewyaxis_label_sv.get() # dow if xaxis_type == None: xaxis_type = self.viewxaxis_label_sv.get() # period if source_type == None or source_value == None: source_type,source_value = self.viewfocus_label_sv.get().split("=") if wratio == None: wratio = self.wratio_label_sv.get().split(",") # what attributes of an object do we want to display # if * is passed that means show the count of the number of records returned if ztypes == None: ztypes = self.viewdata_label_sv.get().split(",") values = ssviewer_utils.dataset_pivot(self.of,self.enums,yaxis_type,xaxis_type,ztypes, source_type,source_value, conflicts_only,constraints,wratio,formatson) if ui==True: self.bgmaxrows=len(values) self.bgmaxcols=len(values[0]) #,wraplength=240 widget_args=dict(background='white',width=1,height=4,highlightbackground='black',highlightthickness=1,values=self.enums['dow']) widgetcfg = nxnarraycreate(self.bgmaxrows,self.bgmaxcols,widget_args) mytextalphanum = TextAlphaNumRO(name='textalphanum') try: self.viewergrid.destroy() except: pass mytextalphanum.widgettype = TkNLabel self.viewergrid = TkImageLabelGrid(self,'viewergrid',mytextalphanum,10,10,0,0,self.bgmaxrows,self.bgmaxcols,True,False,{},widgetcfg,1) self.viewergrid.grid(row=3,column=0,sticky=NSEW) self.grid_rowconfigure(3, weight=10, uniform="foo") for x in range(len(values)): for y in range(len(values[x])): widget = self.viewergrid.widgets[x][y] _value = values[x][y] if isinstance(_value,list) == True: if _value <> []: #if len(_value) == 1 and conflicts_only <> "Y": # replace with line below if want to switch on conflicts if len(_value) == 1: if isinstance(_value[0],tuple) == True: # 1 item, multi attributes bgs,fgs = ssviewer_utils._color_get_multi(_value[0]) _widgets = widget.addlabel(len(_value[0]),True,_value[0],bgs,fgs,wratio) elif isinstance(_value[0],list) == False: # 1 item, single value bg,fg = ssviewer_utils.color_get(_value[0]) _widgets = widget.addlabel(1,True,_value[0],bg,fg) # multiple items #if len(_value) > 1 and conflicts_only == "Y": # replace with line below if want to switch on conflicts if len(_value) > 1: for __value in _value: bgs,fgs = ssviewer_utils._color_get_multi(__value) _widgets = widget.addlabel(len(__value),True,__value,bgs,fgs,wratio) else: expand=False if x == 0 or y == 0: expand=True _widgets = widget.addlabel(expand) _widgets[0].sv.set(_value) else: schema=None if valuetype == True: schema = dict(xaxis=xaxis_type,yaxis=yaxis_type,ztypes=ztypes) values = ssviewer_utils.dataset_serialize(values,formatson,schema=schema) return values self.viewergrid.reset_framewidth() self.viewergrid.resize_canvasframe()
def __init__(self, dbname, of, refdbname, maxentrycols=3, maxentryrows=4, maxnewrowcols=3, maxnewrowrows=3): log.log(thisfuncname(), 3, msg="initialize", dbname=dbname, refdbname=refdbname) self.clipboard = [] self.clipboard_selection = -1 Tk.__init__(self) self.geometry("2000x500+0+0") self.refdatabase = Database(refdbname) #self.enums = sswizard_utils.setenums('All','5',self.refdatabase) self.dbname = dbname self.database = Database(self.dbname) self.of = of font = tkFont.Font(family="monospace", size=12) self.lastsaveversion = 0 style = Style() style.theme_use("default") bigfont = tkFont.Font(family="Helvetica", size=50) self.option_add("*TCombobox*Listbox*Font", bigfont) self.current_inputmode = "Normal" set_configs(style) # any children that change update this # key is the name and value is the new val # the name is likely to be the tkwidgetid.x,y self.updates = OrderedDict() self.maxrows = maxentryrows # rows in the grid self.maxcols = maxentrycols # cols in the grid maxwidgets = self.maxrows * self.maxcols wwidth = 48 # default button width with text of 3 chars wheight = 29 # default button height wmheight = wheight * self.maxrows # master height wmwidth = wwidth * self.maxcols # master width #geom = geometry_get(1000,1000,0,0) #self.geometry(geom) self.bind("<Prior>", self.focus_next_widget) # daygrids setmemberp = SetMemberPartial(name='x{mylist}', set=['Monday']) widget_args = dict(background='white', width=9, font=font, values=['Monday']) widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) # daygrid 1 self.dowentrygrid = TkImageLabelGrid(self, 'dowentrygrid', setmemberp, wmwidth, wmheight, 0, 0, 1, self.maxcols, True, {}, widgetcfg) self.dowentrygrid.grid(row=0, column=0, sticky=EW) # entrygrids setmemberp = SetMemberPartial(name='x{mylist}', set=[]) widget_args = dict(background='white', width=9, font=font, values=[]) widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) # entrygrid 1 setmemberp.widgettype = TkGridCombobox self.entrygrid = TkImageLabelGrid(self, 'entrygrid', setmemberp, wmwidth, wmheight, 0, 0, self.maxrows, self.maxcols, True, True, {}, widgetcfg) self.entrygrid['style'] = 'EntryGrid.TFrame' self.entrygrid.grid(row=1, column=0, sticky=NSEW) buttonpanel = Frame(self, style='ControlPanel.TFrame') buttonpanel.grid(row=2, column=0, sticky=NSEW, columnspan=2) self.save_button = Button(buttonpanel, command=self.save, text="save", name="svb") self.save_button.grid(row=0, column=0) self.save_button.focus_get() self.persist_button = Button(buttonpanel, command=self.persist_lesson, text="persist", name="pb") self.persist_button.grid(row=0, column=1) self.persist_button.focus_get() self.dbload_button = Button(buttonpanel, command=self.load, text="dbload", name="dbl") self.dbload_button.grid(row=0, column=2) self.dbload_button.focus_get() self.clear_button = Button(buttonpanel, command=self.clear, text="clear", name="clr") self.clear_button.grid(row=0, column=3) self.clear_button.focus_get() self.viewer_button = Button(buttonpanel, command=self.viewer, text="viewer", name="view") self.viewer_button.grid(row=0, column=4) self.viewer_button.focus_get() self.rebuilddropdown_button = Button(buttonpanel, command=self.dropdowns_set, text="ddown", name="ddown") self.rebuilddropdown_button.grid(row=0, column=5) self.rebuilddropdown_button.focus_get() controlpanel = Frame(self, style='ControlPanel.TFrame') controlpanel.grid(row=3, column=0, sticky=NSEW, columnspan=2) self.dbload_entry_label = Label(controlpanel, text="version") self.dbload_entry_label.grid(row=0, column=0) self.dbload_entry_label.focus_get() self.dbload_entry_sv = StringVar() self.dbload_entry = Entry(controlpanel, textvariable=self.dbload_entry_sv) self.dbload_entry.grid(row=0, column=1) self.dbload_entry.focus_get() self.dbname_entry_label = Label(controlpanel, text="dbname") self.dbname_entry_label.grid(row=0, column=2) self.dbname_entry_label.focus_get() self.dbname_entry_sv = StringVar() self.dbname_entry = Entry(controlpanel, textvariable=self.dbname_entry_sv) self.dbname_entry.grid(row=0, column=3) self.dbname_entry.focus_get() self.dbname_entry_sv.set(self.dbname) self.dow_entry_label = Label(controlpanel, text="dow", width=10) self.dow_entry_label.grid(row=0, column=4) self.dow_entry_label.focus_get() self.dow_entry_sv = StringVar() self.dow_entry = Entry(controlpanel, textvariable=self.dow_entry_sv, width=10) self.dow_entry.grid(row=0, column=5) self.dow_entry.focus_get() self.dow_entry_sv.set('MO') self.prep_label = Label(controlpanel, text="prep", width=10) self.prep_label.grid(row=0, column=6) self.prep_label.focus_get() self.prep_entry_sv = StringVar() self.prep_entry = Entry(controlpanel, textvariable=self.prep_entry_sv, width=10) self.prep_entry.grid(row=0, column=7) self.prep_entry.focus_get() self.prep_entry_sv.set(5) self.grid_rowconfigure(0, weight=1, uniform="foo") self.grid_rowconfigure(1, weight=10, uniform="foo") self.grid_rowconfigure(2, weight=1, uniform="foo") self.grid_rowconfigure(3, weight=1, uniform="foo") self.grid_columnconfigure(0, weight=1, uniform="foo")
def _createwidget(self,master,gridname,var,width,height,x,y,maxrows,maxcols, scrollbar=True,clipboard=False, gridcfg=None,widgetcfg=None, gridcolstart=0,gridrowstart=0, rowhdrcfg={},colhdrcfg={}): # toplevel self.master = master # reference to ui root Frame.__init__(self,master) self.grid(row=0,column=0,sticky=NSEW) #self.master.grid_rowconfigure(0,weight=1,uniform='foo') #self.master.grid_columnconfigure(0,weight=1,uniform='foo') #self.current_inputmode = self.master.current_inputmode self.clipboard=[] self.clipboard_selection=-1 self.current_inputmode = "Normal" # canvas self.canvas = _tkcanvas(self) self.canvas.pack(side=RIGHT,fill=BOTH,expand=True,anchor=N) # canvasframe self.canvasframe = Frame(self.canvas) self.canvasframe.pack(side = LEFT, fill = BOTH, expand = True,anchor=N) self.canvas_window = self.canvas.create_window((0,0),window=self.canvasframe,anchor=N) vscrollbar = Scrollbar(self,orient="vertical",command=self.canvas.yview) if scrollbar == True: vscrollbar.pack(side=RIGHT,fill=Y) self.canvas.config(yscrollcommand=vscrollbar.set) self.canvas.config(background='white') self.gridname = gridname self.canvasframe.bind("<Configure>",self.resize_canvasframe) self.canvas.bind("<Configure>",self.reset_framewidth) self.current_yfocus=0 self.current_xfocus=0 self.gridcfg = gridcfg self.widgetcfg = widgetcfg self.gridcolstart = gridcolstart self.gridrowstart = gridrowstart self.width=width self.height=height self.x=x self.y=y self.idle = False if self.gridcfg == None: self.gridcfg = nxnarraycreate(maxrows,maxcols) if self.widgetcfg == None: widgetcfg = nxnarraycreate(maxrows,maxcols) self.maxrows = maxrows self.maxcols = maxcols self.label='foobar' self.widgets=[] self.canvasframe.grid_rowconfigure(0,weight=1,uniform='foo') #self.canvasframe.grid_columnconfigure(0,weight=1,uniform='foo') for x in range(self.maxrows): ylbls=[] for y in range(self.maxcols): lbl = tkwidgetfactory(self,var,self.canvasframe,master, name=",".join([gridname,str(x),str(y)]), **widgetcfg[x][y]) lbl.grid(row=x,column=y,sticky=NSEW) ylbls.append(lbl) self.widgets.append(ylbls) for i in range(self.gridcolstart,self.maxcols): self.canvasframe.grid_columnconfigure(i, weight=1, uniform="foo") #for i in range(self.gridrowstart,self.maxrows): # self.canvasframe.grid_rowconfigure(i, weight=1, uniform="foo") if rowhdrcfg <> None: self.header_set(1,**rowhdrcfg) if colhdrcfg <> None: self.header_set(2,**colhdrcfg) self.ic = ImageCreate() if clipboard == True: self.bind_all("<Control-Key>",self.modeset)
def __init__(self,maxentrycols=18,maxentryrows=12, maxnewrowcols=16,maxnewrowrows=3): Tk.__init__(self) self.lastsaveversion=0 # any children that change update this # key is the name and value is the new val # the name is likely to be the tkwidgetid.x,y self.updates = OrderedDict() # clipboard stuff self.clipboard=[] self.clipboard_selection=-1 # dbm columns are added here as they are loaded # .index+1 will give the col # on the grid that corresponds # useful for looking up pk values for updates self.dbcol_defn = [] self.maxrows=maxentryrows # rows in the grid self.maxcols=maxentrycols # cols in the grid #self.maxrows=57 # rows in the grid #self.maxcols=15 # cols in the grid maxwidgets=self.maxrows*self.maxcols wwidth=48 # default button width with text of 3 chars wheight=29 # default button height wmheight=wheight*20 # master height wmwidth=wwidth*20 # master width geom = geometry_get(1500,2000,0,0) self.geometry(geom) #master.bind("<Prior>",self.focus_next_widget) self.bind("<Prior>",self.focus_next_widget) self.grid() font = tkFont.Font(family="monospace", size=10) # entry grid origin label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) mytruefalse = TrueFalse(name='truefalse') self.entrygridolbl = TkImageLabelGrid(self,'entrygridolbl',mytruefalse,2,wmheight, 0,0,1,1,False,{},xlbl_widgetcfg) self.entrygridolbl.grid(row=0,column=0,rowspan=2,sticky=NS) # entry grid y label ylbl_widget_args=dict(width=10,font=font) ylbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,ylbl_widget_args) mytextalphanumro = TextAlphaNum(name='textalphanum') self.entrygridylabel = TkImageLabelGrid(self,'entrygridylbl',mytextalphanumro,2,wmheight, 0,0,1,self.maxcols,False,False,{},ylbl_widgetcfg) self.entrygridylabel.grid(row=0,column=1,sticky=EW) for i in range(self.maxcols): self.entrygridylabel.widgets[0][i].sv.set(i+1) self.entrygridylabel.widgets[0][i]['style'] = 'InFocus.Label.TEntry' # entry grid x label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) mytextalphanum = TextAlphaNum(name='textalphanum') mytextalphanum.widgettype = TkGridEntry #mytruefalse = TrueFalse(name='truefalse') #self.entrygridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytruefalse,2,wmheight, # 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.entrygridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytextalphanum,2,wmheight, 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.entrygridxlabel.grid(row=1,column=0,rowspan=1,sticky=NS) for i in range(self.maxrows): self.entrygridxlabel.widgets[i][0].sv.set(i+1) self.entrygridxlabel.widgets[i][0]['style'] = 'InFocus.Label.TEntry' # entry grid widget_args=dict(background='white',width=20,font=font) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) mytextalphanum = TextAlphaNum(name='textalphanum') mytextalphanum.widgettype = TkGridEntry self.entrygrid = TkImageLabelGrid(self,'entrygrid',mytextalphanum,wmwidth,wmheight, 0,0,self.maxrows,self.maxcols, False,True,{},widgetcfg) self.entrygrid.grid(row=1,column=1,sticky=NSEW) # dbcontrolpanel dbcontrolpanel = Frame(self) dbcontrolpanel.grid(row=2,column=1,sticky=NSEW,padx=10,pady=10) self.dbname_label = Label(dbcontrolpanel,text="database",width=10) self.dbname_label.grid(column=0,row=1,sticky=NSEW) self.dbname_label.focus_get() self.dbname_entry_sv = StringVar() self.dbname_entry = Entry(dbcontrolpanel,textvariable=self.dbname_entry_sv) self.dbname_entry.grid(column=1,row=1,sticky=NSEW) self.dbname_entry.focus_get() self.dbname_entry_sv.set("htmlparser") self.tblname_label = Label(dbcontrolpanel,text="table",width=10) self.tblname_label.grid(column=0,row=2,sticky=NSEW) self.tblname_label.focus_get() self.tblname_entry_sv = StringVar() self.tblname_entry = Entry(dbcontrolpanel,textvariable=self.tblname_entry_sv) self.tblname_entry.grid(column=1,row=2,sticky=NSEW) self.tblname_entry.focus_get() self.tblname_entry_sv.set("lesson") # query predicate 1 self.pred1_label = Label(dbcontrolpanel,text="pred1",width=10) self.pred1_label.grid(column=7,row=1,sticky=NSEW) self.pred1_label.focus_get() self.pred1_entry_sv = StringVar() self.pred1_entry = Entry(dbcontrolpanel,textvariable=self.pred1_entry_sv) self.pred1_entry.grid(column=8,row=1,sticky=NSEW) self.pred1_entry.focus_get() # query predicate value 1 self.pred1_op_entry_sv = StringVar() self.pred1_op_entry = Entry(dbcontrolpanel,textvariable=self.pred1_op_entry_sv) self.pred1_op_entry.grid(column=9,row=1,sticky=NSEW) self.pred1_op_entry.focus_get() self.pred1_op_entry_sv.set("=") self.predval1_entry_sv = StringVar() self.predval1_entry = Entry(dbcontrolpanel,textvariable=self.predval1_entry_sv) self.predval1_entry.grid(column=10,row=1,sticky=NSEW) self.predval1_entry.focus_get() # query predicate 2 self.pred2_label = Label(dbcontrolpanel,text="pred2",width=10) self.pred2_label.grid(column=7,row=2,sticky=NSEW) self.pred2_label.focus_get() self.pred2_entry_sv = StringVar() self.pred2_entry = Entry(dbcontrolpanel,textvariable=self.pred2_entry_sv) self.pred2_entry.grid(column=8,row=2,sticky=NSEW) self.pred2_entry.focus_get() # query predicate value 2 self.pred2_op_entry_sv = StringVar() self.pred2_op_entry = Entry(dbcontrolpanel,textvariable=self.pred2_op_entry_sv) self.pred2_op_entry.grid(column=9,row=2,sticky=NSEW) self.pred2_op_entry.focus_get() self.pred2_op_entry_sv.set("=") self.predval2_entry_sv = StringVar() self.predval2_entry = Entry(dbcontrolpanel,textvariable=self.predval2_entry_sv) self.predval2_entry.grid(column=10,row=2,sticky=NSEW) self.predval2_entry.focus_get() # query predicate 3 self.pred3_label = Label(dbcontrolpanel,text="pred3",width=10) self.pred3_label.grid(column=7,row=3,sticky=NSEW) self.pred3_label.focus_get() self.pred3_entry_sv = StringVar() self.pred3_entry = Entry(dbcontrolpanel,textvariable=self.pred3_entry_sv) self.pred3_entry.grid(column=8,row=3,sticky=NSEW) self.pred3_entry.focus_get() # query predicate value 3 self.pred3_op_entry_sv = StringVar() self.pred3_op_entry = Entry(dbcontrolpanel,textvariable=self.pred3_op_entry_sv) self.pred3_op_entry.grid(column=9,row=3,sticky=NSEW) self.pred3_op_entry.focus_get() self.pred3_op_entry_sv.set("=") self.predval3_entry_sv = StringVar() self.predval3_entry = Entry(dbcontrolpanel,textvariable=self.predval3_entry_sv) self.predval3_entry.grid(column=10,row=3,sticky=NSEW) self.predval3_entry.focus_get() # primary key specifier self.pkentry_label = Label(dbcontrolpanel,text="pk",width=10) self.pkentry_label.grid(column=11,row=1,sticky=NSEW) self.pkentry_label.focus_get() self.pk_entry_sv = StringVar() self.pk_entry = Entry(dbcontrolpanel,textvariable=self.pk_entry_sv) self.pk_entry.grid(column=12,row=1,sticky=NSEW) self.pk_entry.focus_get() self.pk_entry_sv.set("__id") # last query row count self.lastquery_rowcount_label = Label(dbcontrolpanel,text="last row#",width=10) self.lastquery_rowcount_label.grid(column=13,row=1,sticky=NSEW) self.lastquery_rowcount_label.focus_get() self.lastquery_rowcount_text_sv = StringVar() self.lastquery_rowcount_text = Entry(dbcontrolpanel,text=self.lastquery_rowcount_text_sv) self.lastquery_rowcount_text.grid(column=14,row=1,sticky=NSEW) self.lastquery_rowcount_text.focus_get() # last query viewer self.lastquery_label = Label(dbcontrolpanel,text="last query",width=10) self.lastquery_label.grid(column=11,row=2,sticky=NSEW) self.lastquery_label.focus_get() self.lastquery_text_sv = StringVar() self.lastquery_text = Entry(dbcontrolpanel,textvariable=self.lastquery_text_sv) self.lastquery_text.grid(column=12,row=2,sticky=NSEW,columnspan=3) self.lastquery_text.focus_get() # controlpanel controlpanel = Frame(self) controlpanel.grid(row=3,column=1,sticky=NSEW,pady=10,padx=10) self.scrolldelta_label = Label(controlpanel,text="sdelta",width=10) self.scrolldelta_label.grid(column=0,row=0,sticky=NSEW) self.scrolldelta_label.focus_get() self.scrolldelta_label_entry_sv = StringVar() self.scrolldelta_label_entry = Entry(controlpanel,textvariable=self.scrolldelta_label_entry_sv) self.scrolldelta_label_entry.grid(column=1,row=0,sticky=NSEW) self.scrolldelta_label_entry.focus_get() self.scrolldelta_label_entry_sv.set(10) self.hlightpk_label = Label(controlpanel,text="hlight pk",width=10) self.hlightpk_label.grid(column=2,row=0,sticky=NSEW) self.hlightpk_label.focus_get() self.hlightpk_text_sv = StringVar() self.hlightpk_text = Entry(controlpanel,text=self.hlightpk_text_sv) self.hlightpk_text.grid(column=3,row=0,sticky=NSEW) self.hlightpk_text.focus_get() self.inputmode_label = Label(controlpanel,text="hlight pk",width=10) self.inputmode_label.grid(column=4,row=0,sticky=NSEW) self.inputmode_label.focus_get() self.inputmode_value_sv = StringVar() self.inputmode_value = Entry(controlpanel,width=10,textvariable=self.inputmode_value_sv) self.inputmode_value.grid(row=0,column=5) self.inputmode_value.focus_get() self.inputmode_value_sv.set("NORMAL") self.clipboard_size_label = Label(controlpanel,text="hlight pk",width=10) self.clipboard_size_label.grid(column=6,row=0,sticky=NSEW) self.clipboard_size_label.focus_get() self.clipboard_size_value_sv = StringVar() self.clipboard_size_value= Entry(controlpanel,width=10,textvariable=self.clipboard_size_value_sv) self.clipboard_size_value.grid(row=0,column=7) self.clipboard_size_value.focus_get() self.clipboard_size_value_sv.set(0) self.clipboard_selected_label = Label(controlpanel,text="hlight pk",width=10) self.clipboard_selected_label.grid(column=8,row=0,sticky=NSEW) self.clipboard_selected_label.focus_get() self.clipboard_selected_value_sv = StringVar() self.clipboard_selected_value= Entry(controlpanel,width=10,textvariable=self.clipboard_selected_value_sv) self.clipboard_selected_value.grid(row=0,column=9) self.clipboard_selected_value.focus_get() self.clipboard_selected_value_sv.set(self.clipboard_selection) # buttoncontrolpanel buttoncontrolpanel = Frame(self) buttoncontrolpanel.grid(row=4,column=1,sticky=NSEW,pady=10,padx=10) self.dbload_button = Button(buttoncontrolpanel,command=self.load,text="dbload",name="dbl") self.dbload_button.grid(column=0,row=1,sticky=NSEW) self.dbload_button.focus_get() self.clear_button = Button(buttoncontrolpanel,command=self.clear,text="clear",name="clr") self.clear_button.grid(column=1,row=1,sticky=NSEW) self.clear_button.focus_get() self.dbinsert_button = Button(buttoncontrolpanel,command=self.insert,text="dbinsert",name="dbi") self.dbinsert_button.grid(column=2,row=1,sticky=NSEW) self.dbinsert_button.focus_get() self.dbsavechanges_button = Button(buttoncontrolpanel,command=self.process_updates,text="dbsavechgs",name="dbc") self.dbsavechanges_button.grid(column=3,row=1,sticky=NSEW) self.dbsavechanges_button.focus_get() self.clone_button = Button(buttoncontrolpanel,command=self.clone,text="clone",name="cln") self.clone_button.grid(column=4,row=1,sticky=NSEW) self.clone_button.focus_get() self.delrow_button = Button(buttoncontrolpanel,command=self.delrow,text="delrow",name="drw") self.delrow_button.grid(column=5,row=1,sticky=NSEW) self.delrow_button.focus_get() self.pagedown_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('down'), text="DOWN",name="pgd") self.pagedown_button.grid(row=1,column=6,sticky=NSEW) self.pagedown_button.focus_get() self.pageup_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('up'), text="UP",name="pgu") self.pageup_button.grid(row=1,column=7,sticky=NSEW) self.pageup_button.focus_get() self.pageleft_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('left'), text="LEFT",name="pgl") self.pageleft_button.grid(row=1,column=8,sticky=NSEW) self.pageleft_button.focus_get() self.pageright_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('right'), text="RIGHT",name="pgr") self.pageright_button.grid(row=1,column=9,sticky=NSEW) self.pageright_button.focus_get() self.hlightpk_button = Button(buttoncontrolpanel,width=1,command=self.delrow_show, text="PK",name="hlpk") self.hlightpk_button.grid(row=1,column=10,sticky=NSEW) self.hlightpk_button.focus_get() # new row grid x label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) #mytruefalse = TrueFalse(name='truefalse') mytextalphanum = TextAlphaNum(name='textalphanum') mytextalphanum.widgettype = TkGridEntry #self.newrowgridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytruefalse,2,wmheight, # 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.newrowgridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytextalphanum,2,wmheight, 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.newrowgridxlabel.grid(row=5,column=0,rowspan=1,sticky=NS) for i in range(self.maxrows): self.newrowgridxlabel.widgets[i][0].sv.set(i+1) self.newrowgridxlabel.widgets[i][0]['style'] = 'InFocus.Label.TEntry' # new row grid self.maxnewrows=maxnewrowrows self.newrowgrid = TkImageLabelGrid(self,'newrowgrid',mytextalphanum,wmwidth,wmheight, 0,0,self.maxnewrows,self.maxcols, False,False,{},widgetcfg) self.newrowgrid.grid(row=5,column=1,sticky=NSEW) self.grid_columnconfigure(0, weight=1, uniform="foo") self.grid_columnconfigure(1, weight=25, uniform="foo") self.grid_rowconfigure(0, weight=1, uniform="foo") self.grid_rowconfigure(1, weight=15,uniform="foo") self.grid_rowconfigure(5, weight=10, uniform="foo") buttoncontrolpanel.grid_rowconfigure(0, weight=1, uniform="foo") for i in range(10): buttoncontrolpanel.grid_columnconfigure(i, weight=1, uniform="foo")
def __init__(self,maxentrycols=18,maxentryrows=12, maxnewrowcols=16,maxnewrowrows=3): Tk.__init__(self) self.lastsaveversion=0 # any children that change update this # key is the name and value is the new val # the name is likely to be the tkwidgetid.x,y self.updates = OrderedDict() # clipboard stuff self.clipboard=[] self.clipboard_selection=-1 # dbm columns are added here as they are loaded # .index+1 will give the col # on the grid that corresponds # useful for looking up pk values for updates self.dbcol_defn = [] self.maxrows=maxentryrows # rows in the grid self.maxcols=maxentrycols # cols in the grid #self.maxrows=57 # rows in the grid #self.maxcols=15 # cols in the grid maxwidgets=self.maxrows*self.maxcols wwidth=48 # default button width with text of 3 chars wheight=29 # default button height wmheight=wheight*20 # master height wmwidth=wwidth*20 # master width geom = geometry_get(1500,2000,0,0) self.geometry(geom) #master.bind("<Prior>",self.focus_next_widget) self.bind("<Prior>",self.focus_next_widget) self.grid() font = tkFont.Font(family="monospace", size=10) # entry grid origin label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) mytruefalse = TrueFalse(name='truefalse') self.entrygridolbl = TkImageLabelGrid(self,'entrygridolbl',mytruefalse,2,wmheight, 0,0,1,1,False,{},xlbl_widgetcfg) self.entrygridolbl.grid(row=0,column=0,rowspan=2,sticky=NS) # entry grid y label ylbl_widget_args=dict(width=10,font=font) ylbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,ylbl_widget_args) mytextalphanumro = TextAlphaNum(name='textalphanum') self.entrygridylabel = TkImageLabelGrid(self,'entrygridylbl',mytextalphanumro,2,wmheight, 0,0,1,self.maxcols,False,False,{},ylbl_widgetcfg) self.entrygridylabel.grid(row=0,column=1,sticky=EW) for i in range(self.maxcols): self.entrygridylabel.widgets[0][i].sv.set(i+1) self.entrygridylabel.widgets[0][i]['style'] = 'InFocus.Label.TEntry' # entry grid x label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) mytruefalse = TrueFalse(name='truefalse') self.entrygridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytruefalse,2,wmheight, 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.entrygridxlabel.grid(row=1,column=0,rowspan=1,sticky=NS) for i in range(self.maxrows): self.entrygridxlabel.widgets[i][0].sv.set(i+1) self.entrygridxlabel.widgets[i][0]['style'] = 'InFocus.Label.TEntry' # entry grid widget_args=dict(background='white',width=20,font=font) widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,widget_args) mytextalphanum = TextAlphaNum(name='textalphanum') mytextalphanum.widgettype = TkGridEntry self.entrygrid = TkImageLabelGrid(self,'entrygrid',mytextalphanum,wmwidth,wmheight, 0,0,self.maxrows,self.maxcols, False,True,{},widgetcfg) self.entrygrid.grid(row=1,column=1,sticky=NSEW) # dbcontrolpanel dbcontrolpanel = Frame(self) dbcontrolpanel.grid(row=2,column=1,sticky=NSEW,padx=10,pady=10) self.dbname_label = Label(dbcontrolpanel,text="database",width=10) self.dbname_label.grid(column=0,row=1,sticky=NSEW) self.dbname_label.focus_get() self.dbname_entry_sv = StringVar() self.dbname_entry = Entry(dbcontrolpanel,textvariable=self.dbname_entry_sv) self.dbname_entry.grid(column=1,row=1,sticky=NSEW) self.dbname_entry.focus_get() self.dbname_entry_sv.set("htmlparser") self.tblname_label = Label(dbcontrolpanel,text="table",width=10) self.tblname_label.grid(column=0,row=2,sticky=NSEW) self.tblname_label.focus_get() self.tblname_entry_sv = StringVar() self.tblname_entry = Entry(dbcontrolpanel,textvariable=self.tblname_entry_sv) self.tblname_entry.grid(column=1,row=2,sticky=NSEW) self.tblname_entry.focus_get() self.tblname_entry_sv.set("lesson") # query predicate 1 self.pred1_label = Label(dbcontrolpanel,text="pred1",width=10) self.pred1_label.grid(column=7,row=1,sticky=NSEW) self.pred1_label.focus_get() self.pred1_entry_sv = StringVar() self.pred1_entry = Entry(dbcontrolpanel,textvariable=self.pred1_entry_sv) self.pred1_entry.grid(column=8,row=1,sticky=NSEW) self.pred1_entry.focus_get() # query predicate value 1 self.pred1_op_entry_sv = StringVar() self.pred1_op_entry = Entry(dbcontrolpanel,textvariable=self.pred1_op_entry_sv) self.pred1_op_entry.grid(column=9,row=1,sticky=NSEW) self.pred1_op_entry.focus_get() self.pred1_op_entry_sv.set("=") self.predval1_entry_sv = StringVar() self.predval1_entry = Entry(dbcontrolpanel,textvariable=self.predval1_entry_sv) self.predval1_entry.grid(column=10,row=1,sticky=NSEW) self.predval1_entry.focus_get() # query predicate 2 self.pred2_label = Label(dbcontrolpanel,text="pred2",width=10) self.pred2_label.grid(column=7,row=2,sticky=NSEW) self.pred2_label.focus_get() self.pred2_entry_sv = StringVar() self.pred2_entry = Entry(dbcontrolpanel,textvariable=self.pred2_entry_sv) self.pred2_entry.grid(column=8,row=2,sticky=NSEW) self.pred2_entry.focus_get() # query predicate value 2 self.pred2_op_entry_sv = StringVar() self.pred2_op_entry = Entry(dbcontrolpanel,textvariable=self.pred2_op_entry_sv) self.pred2_op_entry.grid(column=9,row=2,sticky=NSEW) self.pred2_op_entry.focus_get() self.pred2_op_entry_sv.set("=") self.predval2_entry_sv = StringVar() self.predval2_entry = Entry(dbcontrolpanel,textvariable=self.predval2_entry_sv) self.predval2_entry.grid(column=10,row=2,sticky=NSEW) self.predval2_entry.focus_get() # query predicate 3 self.pred3_label = Label(dbcontrolpanel,text="pred3",width=10) self.pred3_label.grid(column=7,row=3,sticky=NSEW) self.pred3_label.focus_get() self.pred3_entry_sv = StringVar() self.pred3_entry = Entry(dbcontrolpanel,textvariable=self.pred3_entry_sv) self.pred3_entry.grid(column=8,row=3,sticky=NSEW) self.pred3_entry.focus_get() # query predicate value 3 self.pred3_op_entry_sv = StringVar() self.pred3_op_entry = Entry(dbcontrolpanel,textvariable=self.pred3_op_entry_sv) self.pred3_op_entry.grid(column=9,row=3,sticky=NSEW) self.pred3_op_entry.focus_get() self.pred3_op_entry_sv.set("=") self.predval3_entry_sv = StringVar() self.predval3_entry = Entry(dbcontrolpanel,textvariable=self.predval3_entry_sv) self.predval3_entry.grid(column=10,row=3,sticky=NSEW) self.predval3_entry.focus_get() # primary key specifier self.pkentry_label = Label(dbcontrolpanel,text="pk",width=10) self.pkentry_label.grid(column=11,row=1,sticky=NSEW) self.pkentry_label.focus_get() self.pk_entry_sv = StringVar() self.pk_entry = Entry(dbcontrolpanel,textvariable=self.pk_entry_sv) self.pk_entry.grid(column=12,row=1,sticky=NSEW) self.pk_entry.focus_get() self.pk_entry_sv.set("__id") # last query row count self.lastquery_rowcount_label = Label(dbcontrolpanel,text="last row#",width=10) self.lastquery_rowcount_label.grid(column=13,row=1,sticky=NSEW) self.lastquery_rowcount_label.focus_get() self.lastquery_rowcount_text_sv = StringVar() self.lastquery_rowcount_text = Entry(dbcontrolpanel,text=self.lastquery_rowcount_text_sv) self.lastquery_rowcount_text.grid(column=14,row=1,sticky=NSEW) self.lastquery_rowcount_text.focus_get() # last query viewer self.lastquery_label = Label(dbcontrolpanel,text="last query",width=10) self.lastquery_label.grid(column=11,row=2,sticky=NSEW) self.lastquery_label.focus_get() self.lastquery_text_sv = StringVar() self.lastquery_text = Entry(dbcontrolpanel,textvariable=self.lastquery_text_sv) self.lastquery_text.grid(column=12,row=2,sticky=NSEW,columnspan=3) self.lastquery_text.focus_get() # controlpanel controlpanel = Frame(self) controlpanel.grid(row=3,column=1,sticky=NSEW,pady=10,padx=10) self.scrolldelta_label = Label(controlpanel,text="sdelta",width=10) self.scrolldelta_label.grid(column=0,row=0,sticky=NSEW) self.scrolldelta_label.focus_get() self.scrolldelta_label_entry_sv = StringVar() self.scrolldelta_label_entry = Entry(controlpanel,textvariable=self.scrolldelta_label_entry_sv) self.scrolldelta_label_entry.grid(column=1,row=0,sticky=NSEW) self.scrolldelta_label_entry.focus_get() self.scrolldelta_label_entry_sv.set(10) self.hlightpk_label = Label(controlpanel,text="hlight pk",width=10) self.hlightpk_label.grid(column=2,row=0,sticky=NSEW) self.hlightpk_label.focus_get() self.hlightpk_text_sv = StringVar() self.hlightpk_text = Entry(controlpanel,text=self.hlightpk_text_sv) self.hlightpk_text.grid(column=3,row=0,sticky=NSEW) self.hlightpk_text.focus_get() self.inputmode_label = Label(controlpanel,text="hlight pk",width=10) self.inputmode_label.grid(column=4,row=0,sticky=NSEW) self.inputmode_label.focus_get() self.inputmode_value_sv = StringVar() self.inputmode_value = Entry(controlpanel,width=10,textvariable=self.inputmode_value_sv) self.inputmode_value.grid(row=0,column=5) self.inputmode_value.focus_get() self.inputmode_value_sv.set("NORMAL") self.clipboard_size_label = Label(controlpanel,text="hlight pk",width=10) self.clipboard_size_label.grid(column=6,row=0,sticky=NSEW) self.clipboard_size_label.focus_get() self.clipboard_size_value_sv = StringVar() self.clipboard_size_value= Entry(controlpanel,width=10,textvariable=self.clipboard_size_value_sv) self.clipboard_size_value.grid(row=0,column=7) self.clipboard_size_value.focus_get() self.clipboard_size_value_sv.set(0) self.clipboard_selected_label = Label(controlpanel,text="hlight pk",width=10) self.clipboard_selected_label.grid(column=8,row=0,sticky=NSEW) self.clipboard_selected_label.focus_get() self.clipboard_selected_value_sv = StringVar() self.clipboard_selected_value= Entry(controlpanel,width=10,textvariable=self.clipboard_selected_value_sv) self.clipboard_selected_value.grid(row=0,column=9) self.clipboard_selected_value.focus_get() self.clipboard_selected_value_sv.set(self.clipboard_selection) # buttoncontrolpanel buttoncontrolpanel = Frame(self) buttoncontrolpanel.grid(row=4,column=1,sticky=NSEW,pady=10,padx=10) self.dbload_button = Button(buttoncontrolpanel,command=self.load,text="dbload",name="dbl") self.dbload_button.grid(column=0,row=1,sticky=NSEW) self.dbload_button.focus_get() self.clear_button = Button(buttoncontrolpanel,command=self.clear,text="clear",name="clr") self.clear_button.grid(column=1,row=1,sticky=NSEW) self.clear_button.focus_get() self.dbinsert_button = Button(buttoncontrolpanel,command=self.insert,text="dbinsert",name="dbi") self.dbinsert_button.grid(column=2,row=1,sticky=NSEW) self.dbinsert_button.focus_get() self.dbsavechanges_button = Button(buttoncontrolpanel,command=self.process_updates,text="dbsavechgs",name="dbc") self.dbsavechanges_button.grid(column=3,row=1,sticky=NSEW) self.dbsavechanges_button.focus_get() self.clone_button = Button(buttoncontrolpanel,command=self.clone,text="clone",name="cln") self.clone_button.grid(column=4,row=1,sticky=NSEW) self.clone_button.focus_get() self.delrow_button = Button(buttoncontrolpanel,command=self.delrow,text="delrow",name="drw") self.delrow_button.grid(column=5,row=1,sticky=NSEW) self.delrow_button.focus_get() self.pagedown_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('down'), text="DOWN",name="pgd") self.pagedown_button.grid(row=1,column=6,sticky=NSEW) self.pagedown_button.focus_get() self.pageup_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('up'), text="UP",name="pgu") self.pageup_button.grid(row=1,column=7,sticky=NSEW) self.pageup_button.focus_get() self.pageleft_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('left'), text="LEFT",name="pgl") self.pageleft_button.grid(row=1,column=8,sticky=NSEW) self.pageleft_button.focus_get() self.pageright_button = Button(buttoncontrolpanel, command=lambda: self.pagescroll('right'), text="RIGHT",name="pgr") self.pageright_button.grid(row=1,column=9,sticky=NSEW) self.pageright_button.focus_get() self.hlightpk_button = Button(buttoncontrolpanel,width=1,command=self.delrow_show, text="PK",name="hlpk") self.hlightpk_button.grid(row=1,column=10,sticky=NSEW) self.hlightpk_button.focus_get() # new row grid x label xlbl_widget_args=dict(width=10,font=font) xlbl_widgetcfg = nxnarraycreate(self.maxrows,self.maxcols,xlbl_widget_args) mytruefalse = TrueFalse(name='truefalse') self.newrowgridxlabel = TkImageLabelGrid(self,'entrygridxlbl',mytruefalse,2,wmheight, 0,0,self.maxrows,1,False,False,{},xlbl_widgetcfg) self.newrowgridxlabel.grid(row=5,column=0,rowspan=1,sticky=NS) for i in range(self.maxrows): self.newrowgridxlabel.widgets[i][0].sv.set(i+1) self.newrowgridxlabel.widgets[i][0]['style'] = 'InFocus.Label.TEntry' # new row grid self.maxnewrows=maxnewrowrows self.newrowgrid = TkImageLabelGrid(self,'newrowgrid',mytextalphanum,wmwidth,wmheight, 0,0,self.maxnewrows,self.maxcols, False,False,{},widgetcfg) self.newrowgrid.grid(row=5,column=1,sticky=NSEW) self.grid_columnconfigure(0, weight=1, uniform="foo") self.grid_columnconfigure(1, weight=25, uniform="foo") self.grid_rowconfigure(0, weight=1, uniform="foo") self.grid_rowconfigure(1, weight=15,uniform="foo") self.grid_rowconfigure(5, weight=10, uniform="foo") buttoncontrolpanel.grid_rowconfigure(0, weight=1, uniform="foo") for i in range(10): buttoncontrolpanel.grid_columnconfigure(i, weight=1, uniform="foo")