def __init__(self): # Subclass wx.Frame.__init__(self, None, title=u'testing lrzadmin.py', size=(600, 600)) self.__restart = LorzeRestart() self.__valchck = LorzeValueCheck(self) self.__options = LorzeOptions(self, self.__valchck) self.__dlg = LorzeDlgHelper(self, self.__options) self.__geohelp = LorzeGeoHelp(self.__options) self.__log = LorzeLog() self.__attribute = LorzeAttribute(self.__options, self.__log, self.__valchck) self.__drawman = LorzeDrawManager(self.__attribute, self.__log, self.__geohelp) self.__selection = LorzeSelection(self.__drawman, self.__geohelp) self.__gdi = GraphicPanel(self, self.__options, self.__geohelp, self.__log, self.__valchck, self.__attribute, self.__drawman, self.__selection) # Set attributes, drawings, drawing elements self.set_attr_draw_elem() self.__gdi.set_wx_colordic() self.__gdi.set_wx_styledic() self.__gdi.set_wx_widthdic() self.__testing = ('GUI with GDI panel', 'Options dialogue', 'About dialogue', 'Help dialogue', 'Load dialogue', 'Save dialogue', 'Color dialogue', 'Text dialogue', 'List dialogue', 'Selection drawing dialogue | default', 'Selection drawing dialogue | 1 selected', 'Selection drawing dialogue | 3 selected', 'Selection colour dialogue | default', 'Selection colour dialogue | options', 'Selection colour dialogue | 1 selected', 'Selection colour dialogue | 3 selected', 'Selection layer dialogue | default', 'Selection layer dialogue | options', 'Selection layer dialogue | 1 selected', 'Selection layer dialogue | 3 selected', 'Selection line style dialogue | default', 'Selection line style dialogue | options', 'Selection line style dialogue | 1 selected', 'Selection line style dialogue | 3 selected', 'LorzeLog dialouge', '') # Listbox self.__list = wx.ListBox(self, size=(-1, -1), choices=self.__testing) self.__list.SetSelection(0) buttonexit = wx.Button(self, label=u'Exit') # bindings buttonexit.Bind(wx.EVT_BUTTON, self.on_exit) self.__list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list) self.__list.Bind(wx.EVT_KEY_DOWN, self.on_key_down) # layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.__list, 1, wx.EXPAND | wx.ALL, 5) vbox.Add(buttonexit, 0, wx.EXPAND | wx.ALL, 5) self.__list.SetFocus() self.SetSizer(vbox) self.Centre() self.Show()
class TestFrame(wx.Frame): ''' object for testing''' def __init__(self): # Subclass wx.Frame.__init__(self, None, title=u'testing lrzadmin.py', size=(600, 600)) self.__restart = LorzeRestart() self.__valchck = LorzeValueCheck(self) self.__options = LorzeOptions(self, self.__valchck) self.__dlg = LorzeDlgHelper(self, self.__options) self.__geohelp = LorzeGeoHelp(self.__options) self.__log = LorzeLog() self.__attribute = LorzeAttribute(self.__options, self.__log, self.__valchck) self.__drawman = LorzeDrawManager(self.__attribute, self.__log, self.__geohelp) self.__selection = LorzeSelection(self.__drawman, self.__geohelp) self.__gdi = GraphicPanel(self, self.__options, self.__geohelp, self.__log, self.__valchck, self.__attribute, self.__drawman, self.__selection) # Set attributes, drawings, drawing elements self.set_attr_draw_elem() self.__gdi.set_wx_colordic() self.__gdi.set_wx_styledic() self.__gdi.set_wx_widthdic() self.__testing = ('GUI with GDI panel', 'Options dialogue', 'About dialogue', 'Help dialogue', 'Load dialogue', 'Save dialogue', 'Color dialogue', 'Text dialogue', 'List dialogue', 'Selection drawing dialogue | default', 'Selection drawing dialogue | 1 selected', 'Selection drawing dialogue | 3 selected', 'Selection colour dialogue | default', 'Selection colour dialogue | options', 'Selection colour dialogue | 1 selected', 'Selection colour dialogue | 3 selected', 'Selection layer dialogue | default', 'Selection layer dialogue | options', 'Selection layer dialogue | 1 selected', 'Selection layer dialogue | 3 selected', 'Selection line style dialogue | default', 'Selection line style dialogue | options', 'Selection line style dialogue | 1 selected', 'Selection line style dialogue | 3 selected', 'LorzeLog dialouge', '') # Listbox self.__list = wx.ListBox(self, size=(-1, -1), choices=self.__testing) self.__list.SetSelection(0) buttonexit = wx.Button(self, label=u'Exit') # bindings buttonexit.Bind(wx.EVT_BUTTON, self.on_exit) self.__list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list) self.__list.Bind(wx.EVT_KEY_DOWN, self.on_key_down) # layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.__list, 1, wx.EXPAND | wx.ALL, 5) vbox.Add(buttonexit, 0, wx.EXPAND | wx.ALL, 5) self.__list.SetFocus() self.SetSizer(vbox) self.Centre() self.Show() def on_exit(self, event): '''Event, exit program''' self.exit_frame() def on_list(self, event): '''Event, read selection in the list''' self.get_selection() def on_key_down(self, event): '''Event, get key''' if event.GetKeyCode() == wx.WXK_ESCAPE: self.exit_frame() elif event.GetKeyCode() == wx.WXK_RETURN: self.get_selection() elif event.GetKeyCode() == wx.WXK_NUMPAD_ENTER: self.get_selection() def exit_frame(self): '''Close the program''' self.Close() def get_selection(self): '''Run the entry in the list''' self.__cmd = self.__testing[self.__list.GetSelection()] if self.__cmd == 'GUI with GDI panel': LorzeGUI(self.__restart) if self.__cmd == 'Options dialogue': self.show_options_dlg() elif self.__cmd == 'About dialogue': LorzeAbout(self.__options) elif self.__cmd == 'Help dialogue': self.show_help_dlg() elif self.__cmd == 'Load dialogue': self.show_load_dlg() elif self.__cmd == 'Save dialogue': self.show_save_dlg() elif self.__cmd == 'Color dialogue': self.show_color_dlg() elif self.__cmd == 'Text dialogue': self.show_text_dlg() elif self.__cmd == 'List dialogue': self.show_list_dlg() # drawing selection elif self.__cmd == 'Selection drawing dialogue | default': self.show_seldraw_dlg('default') elif self.__cmd == 'Selection drawing dialogue | 1 selected': self.show_seldraw_dlg('1 selected') elif self.__cmd == 'Selection drawing dialogue | 3 selected': self.show_seldraw_dlg('3 selected') # colour selection elif self.__cmd == 'Selection colour dialogue | default': self.show_selclsw_dlg('default', 'color') elif self.__cmd == 'Selection colour dialogue | options': self.show_selclsw_dlg('options', 'color') elif self.__cmd == 'Selection colour dialogue | 1 selected': self.show_selclsw_dlg('1 selected', 'color') elif self.__cmd == 'Selection colour dialogue | 3 selected': self.show_selclsw_dlg('3 selected', 'color') # layer selection elif self.__cmd == 'Selection layer dialogue | default': self.show_selclsw_dlg('default', 'layer') elif self.__cmd == 'Selection layer dialogue | options': self.show_selclsw_dlg('options', 'layer') elif self.__cmd == 'Selection layer dialogue | 1 selected': self.show_selclsw_dlg('1 selected', 'layer') elif self.__cmd == 'Selection layer dialogue | 3 selected': self.show_selclsw_dlg('3 selected', 'layer') # style selection elif self.__cmd == 'Selection line style dialogue | default': self.show_selclsw_dlg('default', 'style') elif self.__cmd == 'Selection line style dialogue | options': self.show_selclsw_dlg('options', 'style') elif self.__cmd == 'Selection line style dialogue | 1 selected': self.show_selclsw_dlg('1 selected', 'style') elif self.__cmd == 'Selection line style dialogue | 3 selected': self.show_selclsw_dlg('3 selected', 'style') # lorzelog elif self.__cmd == 'LorzeLog dialouge': self.show_lorzelog_dlg() def get_gdi_size(self): '''Simulate the method from LorzeGUI, return framesize''' return(self.GetSize()) def set_status_mouse(self, x, y): '''Simulate the method from LorzeGUI, do nothing''' pass def get_borders_dict(self): '''Get __bordersdict.''' return({'simple': wx.SIMPLE_BORDER, 'raised': wx.RAISED_BORDER, 'sunken': wx.SUNKEN_BORDER, 'no': wx.NO_BORDER}) def get_cursors_dict(self): '''Get __cursorsdict.''' return({'arrow': wx.CURSOR_ARROW, 'right arrow': wx.CURSOR_RIGHT_ARROW, 'blank': wx.CURSOR_BLANK, 'bullseye': wx.CURSOR_BULLSEYE, 'char': wx.CURSOR_CHAR, 'cross': wx.CURSOR_CROSS, 'hand': wx.CURSOR_HAND, 'ibeam': wx.CURSOR_IBEAM, 'left button': wx.CURSOR_LEFT_BUTTON, 'magnifier': wx.CURSOR_MAGNIFIER, 'middle button': wx.CURSOR_MIDDLE_BUTTON, 'no entry': wx.CURSOR_NO_ENTRY, 'paint brush': wx.CURSOR_PAINT_BRUSH, 'pencil': wx.CURSOR_PENCIL, 'point left': wx.CURSOR_POINT_LEFT, 'point right': wx.CURSOR_POINT_RIGHT, 'question arrow': wx.CURSOR_QUESTION_ARROW, 'right button': wx.CURSOR_RIGHT_BUTTON, 'sizenesW': wx.CURSOR_SIZENESW, 'sizens': wx.CURSOR_SIZENS, 'sizenwse': wx.CURSOR_SIZENWSE, 'sizewe': wx.CURSOR_SIZEWE, 'sizing': wx.CURSOR_SIZING, 'spraycan': wx.CURSOR_SPRAYCAN, 'wait': wx.CURSOR_WAIT, 'watch': wx.CURSOR_WATCH, 'arrowwait': wx.CURSOR_ARROWWAIT, 'default': wx.CURSOR_DEFAULT}) def get_line_style_dict(self): '''Get __linstyldict.''' return({'solid': wx.SOLID, 'dot': wx.DOT, 'long dash': wx.LONG_DASH, 'short dash': wx.SHORT_DASH, 'dot dash': wx.DOT_DASH, 'user dash': wx.USER_DASH}) def set_attr_draw_elem(self): '''Set attributes and elements for testing.''' # Add colour entrys. for i in [('Red', 'FF0000', 'base color'), ('Blue', '0000FF', 'base color'), ('Green', '008000', 'base color'), ('Yellow', 'FFFF00', 'base color'), ('Gray', '808080', 'base color'), ('White', 'FFFFFF', 'base color')]: self.__attribute.add_color_entry(i[0], i[1], i[2]) # Add layer entrys. for i in [('Layer 1', 'default'), ('Layer 2', 'default'), ('Layer 3', 'default'), ('Layer 4', 'default'), ('Layer 5', 'default'), ('Layer 6', 'default')]: self.__attribute.add_layer_entry(i[0], i[1]) # Add line style entrys. for i in [('Solid', ('solid | '), 'standard'), ('Dot', ('dot | '), 'standard'), ('Long dash', ('long dash | '), 'standard'), ('Short dash', ('short dash | '), 'standard'), ('Dot dash', ('dot dash | '), 'standard'), ('Axis 13mm', ('user dash | 10, 2, 1, 2'), 'standard')]: self.__attribute.add_style_entry(i[0], i[1], i[2]) # Add line width entrys. for i in [('0.13mm', '0.13', 'Rotring'), ('0.18mm', '0.18', 'Rotring'), ('0.25mm', '0.25', 'Rotring'), ('0.35mm', '0.35', 'Rotring'), ('0.50mm', '0.50', 'Rotring'), ('0.70mm', '0.70', 'Rotring')]: self.__attribute.add_width_entry(i[0], i[1], i[2]) # Add 3 drawings self.__drawman.add_drawing('lrzwxtest 1') self.__drawman.add_drawing('lrzwxtest 2') self.__drawman.add_drawing('lrzwxtest 3') # 6 lines line1 = ('L', ('Red', 'Layer 1', 'Solid', '0.13mm', (1, 1, 10, 10))) line2 = ('L', ('Blue', 'Layer 2', 'Dot', '0.18mm', (2, 2, 20, 20))) line3 = ('L', ('Green', 'Layer 3', 'Long dash', '0.25mm', (3, 3, 30, 30))) line4 = ('L', ('Yellow', 'Layer 4', 'Short dash', '0.35mm', (4, 4, 40, 40))) line5 = ('L', ('Gray', 'Layer 5', 'Dot dash', '0.50mm', (5, 5, 50, 50))) line6 = ('L', ('White', 'Layer 6', 'Axis 13mm', '0.70mm', (6, 6, 60, 60))) # Add 6 lines in 3 drawings for i in [('lrzwxtest 1', line1, line2), ('lrzwxtest 2', line3, line4), ('lrzwxtest 3', line5, line6)]: drawing, element1, element2 = i self.__drawman.set_default_draw(drawing) for j in (element1, element2): typ, attr = j self.__drawman.get_drawing(drawing).add_(typ, attr) def show_options_dlg(self): dlg = LorzeDlgOptions(self, self.__options, self.__valchck, self.__dlg) dlg.ShowModal() restart = dlg.get_restart() dlg.Destroy() if restart: text = '' for i in ('gdiborder', 'cursorwin', 'cursordraw', 'cursorselect', 'sccolpoint', 'sccolsegm', 'sccolelem', 'prevcol', 'prevstyle', 'selcol', 'defcolorname', 'defcolorvalue', 'defcolorlabel', 'deflayername', 'deflayerlabel', 'defstylename', 'defstylevalue', 'defstylelabel', 'defwidthname', 'defwidthvalue', 'defwidthlabel', 'framewidth', 'frameheight', 'dezplcs', 'dlgborder', 'dlgoptwidth', 'dlgoptheight', 'sbrange', 'sbsize', 'sensitive', 'maxstylescale', 'maxuserscale', 'scsize', 'scwidth', 'prevwidth', 'stcoordw', 'optlistwidth0', 'optlistwidth1', 'dlghelpwidth', 'dlghelpheight', 'dlglistselwidth', 'dlglistselheight', 'dlgseldrawwidth', 'dlgseldrawheight', 'dlgselcolwidth', 'dlgselcolheight', 'collistwidth0', 'collistwidth1', 'collistwidth2', 'collistwidth3', 'dlgnewcolwidth', 'dlgnewcolheight', 'wheelmagnif', 'wheelreduce', 'scmarksize'): text = text + i + ': ' + \ str(self.__options.get_(i)) + '\n' print(self.__cmd) print(text) dlg = wx.MessageDialog(self, 'The options are changed. ' + \ 'You have to restart lrzwxtest.py', self.__cmd, style=wx.OK) dlg.ShowModal() dlg.Destroy() self.Close() def show_help_dlg(self): dlg = LorzeHelp(self, self.__options) dlg.ShowModal() dlg.Destroy() def show_load_dlg(self): text = self.__dlg.open_dialog('Load dialog', '/', 'Test.txt', 'Text (*.txt) | *.txt | All (*.*) | *.*') print(self.__cmd) print(text) def show_save_dlg(self): text = self.__dlg.save_dialog('Save dialog', '/', 'Test.txt', 'Text (*.txt) | *.txt | All (*.*) | *.*', '.txt') print(self.__cmd) print(text) def show_color_dlg(self): text = self.__dlg.color_dialog('#FFFFFF') print(self.__cmd) print(text) def show_text_dlg(self): text = self.__dlg.text_dialog('Test', 'Testeingabe ..', '123') print(self.__cmd) print(text) def show_list_dlg(self): text = self.__dlg.list_selection('List-Test', ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], 'e') print(self.__cmd) print(text) def show_seldraw_dlg(self, mode): if mode == 'default': self.__selection.clear() elif mode == '1 selected': self.__selection.clear() self.__selection.add_remove('L0', 'lrzwxtest 1') elif mode == '3 selected': self.__selection.clear() self.__selection.add_remove('L0', 'lrzwxtest 1') self.__selection.add_remove('L0', 'lrzwxtest 2') self.__selection.add_remove('L0', 'lrzwxtest 3') seldlg = LorzeDlgSelDrawing(self, self.__options, self.__drawman, self.__selection) seldlg.ShowModal() drawing = seldlg.get_choice() seldlg.Destroy() #~ dlg = wx.MessageDialog(self, drawing, self.__cmd, style=wx.OK) #~ dlg.ShowModal() #~ dlg.Destroy() print(self.__cmd) print(drawing) def show_lorzelog_dlg(self): dlg = LorzeDlgLog(self, self.__options, self.__log) dlg.ShowModal() dlg.Destroy() def show_selclsw_dlg(self, mode, typ): if mode == 'default': self.__selection.clear() elif mode == 'options': self.__selection.clear() elif mode == '1 selected': self.__selection.clear() self.__selection.add_remove('L0', 'lrzwxtest 1') mode == 'selected' elif mode == '3 selected': self.__selection.clear() self.__selection.add_remove('L0', 'lrzwxtest 1') self.__selection.add_remove('L0', 'lrzwxtest 2') self.__selection.add_remove('L0', 'lrzwxtest 3') mode == 'selected' seldlg = LorzeDlgSelCLSW(self, typ, mode, self.__options, self.__attribute, self.__drawman, self.__selection, self.__dlg, self.__valchck) seldlg.ShowModal() attr = seldlg.get_choice() newlist = seldlg.get_new_created() seldlg.Destroy() print(self.__cmd) if attr == '__cancel': print('Cancel') elif attr == '__default': print('No changes in ' + typ) print('New created '+ typ + 's', newlist) else: print('Chosen ' + typ, attr) print('New created '+ typ + 's', newlist)