class TestUIGrid7x5odd(TestWidget): def setUp(self): self.master = Tk() self.maxrows = 7 # rows in the grid self.maxcols = 5 # 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 self.mytextalphanum = TextAlphaNum(name='textalphanum') self.tkilg = TkImageLabelGrid(self.master, 'grid', self.mytextalphanum, self.wmwidth, self.wmheight, 0, 0, 7, 5) 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") def test_master(self): exp_results = dict(height=self.wmheight, width=self.wmwidth, x=0, y=0) self.assertWidgetDimensions(self.master, 0.01, **exp_results) self.assertEquals(len(self.master.children), self.maxwidgets) def test_middle(self): row = 2 col = 3 widget = self.tkilg.widgets[2][3] exp_results = dict(height=self.wheight, width=self.wwidth, x=self.wwidth * col, y=self.wheight * row) self.assertWidgetDimensions(widget, 0.01, **exp_results) def test_bottomright(self): row = 6 col = 4 widget = self.tkilg.widgets[6][4] exp_results = dict(height=self.wheight, width=self.wwidth, x=self.wwidth * col, y=self.wheight * row) self.assertWidgetDimensions(widget, 0.01, **exp_results) def tearDown(self): self.master.destroy()
class UI(Tk): def __init__(self): Tk.__init__(self) self.maxrows = 2 # rows in the grid self.maxcols = 2 # cols in the grid self.wmheight = 400 # master height self.wmwidth = 400 # master width image_args = dict(pointsize=48, font='Helvetica', gravity='center', rotate=90, label='foobar') gridcfg = nxnarraycreate(self.maxrows, self.maxcols, image_args) widget_args = dict(values=[ 'peach', 'pomegranate', 'passionfruit', 'pear', 'grape', 'strawberry', 'raspberry', 'rhubarb', 'mango', 'guava', 'apple', 'Orange' ]) widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) self.setmemberp = SetMemberPartial( name='x{mylist}', set=[ 'pineapple', 'grapefruit', 'banana', 'peach', 'pomegranate', 'passionfruit', 'pear', 'grape', 'strawberry', 'raspberry', 'rhubarb', 'mango', 'guava', 'apple', 'Orange' ]) #self.tkilg = TkImageLabelGrid(self.master,'grid',self.setmemberp,self.wmwidth,self.wmheight, # 0,0,self.maxrows,self.maxcols, # gridcfg,widgetcfg) self.tkilg = TkImageLabelGrid(self.master, 'grid', self.setmemberp, self.wmwidth, self.wmheight, 0, 0, self.maxrows, self.maxcols, True, True, gridcfg, widgetcfg, 0, 0) 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")
class Test_Grid_Scrollbars(unittest.TestCase): def setUp(self): self.master = Tk() setmemberp = SetMemberPartial(name='x{mylist}', set=['foo', 'bar']) widget_args = dict(background='white', values=['foo', 'bar']) widgetcfg = nxnarraycreate(60, 10, widget_args) self.entrygrid = TkImageLabelGrid(self.master, 'entrygrid', setmemberp, 500, 500, 0, 0, 30, 5, True, {}, widgetcfg) self.entrygrid.grid(row=0, column=0, sticky=NSEW) def test_(self): #self.master.mainloop() pass def tearDown(self): self.master.destroy()
class UI(Tk): def __init__(self): Tk.__init__(self) self.maxrows = 13 # rows in the grid self.maxcols = 13 # cols in the grid self.wmheight = 1300 # master height self.wmwidth = 1200 # master width custommaster = dict(height=self.wmheight, width=self.wmwidth, x=0, y=0) self.geometry(geometry_get(**custommaster)) image_args = dict(pointsize=24, font='Helvetica', gravity='center', rotate=0, label='foobar') gridcfg = nxnarraycreate(self.maxrows, self.maxcols, image_args) widget_args = {'background': 'white'} widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) self.mytextalphanumro = TextAlphaNumRO(name='textalphanum') self.tkilg = TkImageLabelGrid(self.master, 'grid', self.mytextalphanumro, self.wmwidth, self.wmheight, 0, 0, self.maxrows, self.maxcols, True, True, gridcfg, 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")
class TestUIGridCustom(TestWidget): # tests having top and side header rows/columns a different width def setUp(self): self.master = Tk() self.maxrows = 7 # rows in the grid self.maxcols = 5 # cols in the grid #self.maxwidgets=self.maxrows*self.maxcols self.wmheight = 500 # master height self.wmwidth = 500 # master width image_args = dict(pointsize=48, font='Helvetica', gravity='center', rotate=90, label='foobar') gridcfg = nxnarraycreate(self.maxrows, self.maxcols, image_args) widget_args = dict(background='white', text='foo', borderwidth=2) widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) rowcfg = dict(width=2, foreground='yellow', text="x", background='green') colcfg = dict(height=2, foreground='yellow', text="y", background='green') self.mytextalphanumro = TextAlphaNumRO(name='textalphanum') self.tkilg = TkImageLabelGrid(self.master, 'grid', self.mytextalphanumro, self.wmwidth, self.wmheight, 0, 0, self.maxrows, self.maxcols, True, True, gridcfg, widgetcfg, 0, 0, rowcfg, colcfg) self.tkilg.cell_set(0, 0, **dict(background='white', width=2, height=2)) self.tkilg.cell_set(1, 1, **dict(background='pink', width=2, height=2)) 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") def test_origin(self): exp_results = dict(height=36, width=22, x=0, y=0) self.assertWidgetDimensions(self.tkilg.widgets[0][0], 0.01, **exp_results) def test_topheader(self): exp_results = dict(height=36, width=120, x=22, y=0) self.assertWidgetDimensions(self.tkilg.widgets[0][1], 0.01, **exp_results) def test_left_leftheader(self): exp_results = dict(height=77, width=22, x=0, y=36) self.assertWidgetDimensions(self.tkilg.widgets[1][0], 0.01, **exp_results) def tearDown(self): self.master.destroy()
class TestUILabelImageGridCustom(TestWidget): def setUp(self): self.master = Tk() self.geom = geometry_get(300, 300, 0, 0) self.master.geometry(self.geom) self.maxrows = 7 # rows in the grid self.maxcols = 5 # cols in the grid #self.maxwidgets=self.maxrows*self.maxcols self.wmheight = 500 # master height self.wmwidth = 500 # master width image_args = dict(pointsize=16, font='Helvetica', gravity='center', rotate=0, label='foobar') gridcfg = nxnarraycreate(self.maxrows, self.maxcols, image_args) widget_args = dict(background='black', text='foo') widgetcfg = nxnarraycreate(self.maxrows, self.maxcols, widget_args) rowcfg = dict(height=2, fg='yellow', text="x") colcfg = dict(width=2, fg='yellow', text="y") self.mytextalphanumro = TextAlphaNumRO(name='textalphanum') self.tkilg = TkImageLabelGrid(self.master, 'grid', self.mytextalphanumro, self.wmwidth, self.wmheight, 0, 0, self.maxrows, self.maxcols, True, False, gridcfg, widgetcfg, 1, 1, rowcfg, colcfg) self.tkilg.grid(row=0, column=0, sticky=NSEW) self.tkilg.cell_set(0, 0, **dict(background='yellow', width=2, height=2)) self.tkilg.cell_set(1, 1, **dict(background='pink', width=2, height=2)) self.master.grid_rowconfigure(0, weight=1, uniform="foo") self.master.grid_columnconfigure(0, weight=1, uniform="foo") self.tkilg.image_set() def test_origin(self): #self.tkilg.image_set() #self.tkilg.image_show() exp_results = dict(height=34, width=20, x=0, y=0) #self.assertWidgetDimensions(self.tkilg.widgets[0][0],0.01,**exp_results) #self.master.mainloop() '''def test_topheader(self): exp_results = dict(height=34,width=120,x=20,y=0) self.assertWidgetDimensions(self.tkilg.widgets[0][1],0.01,**exp_results) #self.master.mainloop() def test_left_leftheader(self): exp_results = dict(height=77,width=20,x=0,y=34) self.assertWidgetDimensions(self.tkilg.widgets[1][0],0.01,**exp_results) #self.master.mainloop()''' def tearDown(self): self.master.destroy()