def __init__(self, parent): super().__init__(parent=parent) self.parent = parent text = """ <html><body bgcolor="#F78181"><center> <table bgcolor="#FBFBEF" width="100%" cellspacing="0" cellpadding="0" border="1"> <tr><td align="center"><h1>Rubrica v3.0</h1></td></tr></table></center> <p><b>Rubrica</b> is a simple phone-book realized with:<br> <b>- wxPython 4.0</b> for Graphics<br> <b>- Sqlite</b> for database structure<br> <b>- SQLAlchemy</b> for Object Relation Mapping<br> I've tried to use a Model-View-Controller pattern-like.<br> web-site: <b>www.bancaldo.wordpress.com</b><br> last revision: may 17, 2015</p></body></html> """ html = wx.html.HtmlWindow(self) html.SetPage(text) self.btn_quit = GenBitmapTextButton(self, wx.ID_ANY, wx.Bitmap("%sexit.png" % IMG_PATH), 'Exit'.rjust(20), (350, 150)) self.btn_quit.SetBezelWidth(1) self.btn_quit.SetBackgroundColour(BTN_BG) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(html, 1, wx.EXPAND | wx.ALL, 5) sizer.Add(self.btn_quit, 0, wx.ALIGN_CENTER | wx.EXPAND, 5) self.SetSizer(sizer)
def answer_button(self, txt, size=(150, 150)): btn = GenBitmapTextButton(self, bitmap=self.render(txt), label="\n", size=size) btn.SetBackgroundColour('#fcff9c') return btn
def question_button(self, txt, word, size=(150, 150)): btn = GenBitmapTextButton(self, bitmap=self.render(txt, word), label="\n", size=size) btn.SetBackgroundColour('#c2e6f8') return btn
def __init__(self, parent, label="Close"): """Constructor""" font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD) img = wx.Bitmap(r"%s/images/cancel.png" % appPath) GenBitmapTextButton.__init__(self, parent, wx.ID_CLOSE, img, label=label, size=(110, 50)) self.SetFont(font)
def __init__(self, *args, **kwargs): """ :param parent: (wx.Window) parent window :param id: (int) button id (optional) :param bitmap: (wx.Bitmap) default button face. Use `SetBitmaps` to set the other faces (e.g. hover, active) :param pos: (int, int)) button position :param size: (int, int) button size :param background_parent: (wx.Window) any parent higher up in the hierarchy from which to pick the background colour. (optional) :param label_delta: (int) the number of pixels to move button text down and to the right when it is pressed, to create an indentation effect. (This is used by subclasses that allow text to be displayed) :param rescale: (bool) if set to True and the button has a size, the background image will be scaled to fit the button. """ kwargs['style'] = kwargs.get('style', 0) | wx.NO_BORDER self.labelDelta = kwargs.pop('label_delta', 0) self.rescale = kwargs.pop('rescale', False) self.background_parent = kwargs.pop('background_parent', None) # Fit the bmp if needed # Resizing should always be minimal, so distortion is minimum # If the bmp arg is provided (which is the 3rd one: parent, id, bmp) bmp = args[2] if len(args) >= 3 else kwargs.get('bitmap', None) size = args[4] if len(args) >= 5 else kwargs.get('size', None) if bmp: if size and size != (-1, -1): args = list(args) # Resize and replace original bmp if len(args) >= 3: args[2] = resize_bmp(size, bmp) else: kwargs['bitmap'] = resize_bmp(size, bmp) else: # Set the size of the button to match the bmp if len(args) >= 5: args[4] = bmp.GetSize() else: kwargs['size'] = bmp.GetSize() GenBitmapTextButton.__init__(self, *args, **kwargs) self.bmpHover = None self.hovering = False self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
def __init__(self, parent, data, title=u'Aviso de Entrega!'): """ Método construtor do Dialog para """ wx.Dialog.__init__(self, parent, wx.ID_ANY, title, size=(500, 230)) self.Centre() self.image = None self.data = data self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) textbox_message = wx.TextCtrl(self, wx.ID_ANY, self.get_message(), pos=(75, 50), size=(400, 90), style=wx.NO_BORDER | wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.TE_BESTWRAP) textbox_message.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) panel_side_buttons = wx.Panel(self, pos=(100, 150), size=(370, 40), style=wx.SIMPLE_BORDER) button_show_more = GenBitmapTextButton( panel_side_buttons, wx.ID_ANY, wx.Bitmap(core.directory_paths['icons'] + 'Search.png'), u'Ver Mais', pos=(0, 0), size=(100, 40)) button_ok = GenBitmapTextButton( panel_side_buttons, wx.ID_OK, wx.Bitmap(core.directory_paths['icons'] + 'Check.png'), u'OK', pos=(100, 0), size=(100, 40)) button_done = GenBitmapTextButton( panel_side_buttons, wx.ID_EXIT, wx.Bitmap(core.directory_paths['icons'] + 'Delivery.png'), self.text_done, pos=(200, 0), size=(170, 40), style=wx.BU_LEFT) button_show_more.Bind(wx.EVT_BUTTON, self.more) button_ok.Bind(wx.EVT_BUTTON, self.exit) button_done.Bind(wx.EVT_BUTTON, self.ready) panel_side_buttons.SetFocus() wx.EVT_PAINT(self, self.OnPaint)
class CorePanel(wx.Panel): def __init__(self, parent): super(CorePanel, self).__init__(parent=parent) self.parent = parent self.btn_info = GenBitmapTextButton(self, -1, wx.Bitmap("%sinfo.png" % IMG_PATH), size=(280, 45)) self.btn_info.SetToolTip("About...") self.btn_add = GenBitmapTextButton(self, -1, wx.Bitmap("%sadd.png" % IMG_PATH), size=(280, 45)) self.btn_add.SetToolTip("Add new Contact to database") self.btn_delete = GenBitmapTextButton(self, -1, wx.Bitmap("%sdelete.png" % IMG_PATH), size=(280, 45)) self.btn_delete.SetToolTip("Delete an Existing Contact") self.btn_find = GenBitmapTextButton(self, -1, wx.Bitmap("%ssearch.png" % IMG_PATH), size=(280, 45)) self.btn_find.SetToolTip("Find Contacts by Surname") self.btn_exit = GenBitmapTextButton(self, -1, wx.Bitmap("%sexit.png" % IMG_PATH), size=(280, 45)) self.btn_exit.SetToolTip("Exit...") for widget in self.GetChildren(): if isinstance(widget, GenBitmapTextButton): widget.SetBezelWidth(1) widget.SetBackgroundColour(BTN_BG) # BUTTONS SIZER sizer = wx.FlexGridSizer(rows=5, cols=1, hgap=5, vgap=0) sizer.Add(self.btn_info, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_add, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_delete, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_find, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_exit, 0, wx.EXPAND | wx.ALL, 4) sizer.AddGrowableCol(0) self.SetSizer(sizer)
def __init__(self, parent, month, title=u'Tabelas', sheet_to_focus=1): wx.Frame.__init__(self, parent, -1, title, size=(970, 600)) self.month = month self.parent = parent self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.SetIcon(wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO)) box = wx.BoxSizer(wx.VERTICAL) note = wx.Notebook(self, style=wx.LEFT) if sheet_to_focus == 1: self.main1 = Sheet(note, 'won') self.main2 = Sheet(note, 'loss') self.main3 = Sheet(note, 'prod') self.main4 = Sheet(note, 'was') elif sheet_to_focus == 2: self.main2 = Sheet(note, 'loss') self.main3 = Sheet(note, 'prod') self.main4 = Sheet(note, 'was') self.main1 = Sheet(note, 'won') elif sheet_to_focus == 3: self.main3 = Sheet(note, 'prod') self.main4 = Sheet(note, 'was') self.main1 = Sheet(note, 'won') self.main2 = Sheet(note, 'loss') elif sheet_to_focus == 4: self.main4 = Sheet(note, 'was') self.main1 = Sheet(note, 'won') self.main2 = Sheet(note, 'loss') self.main3 = Sheet(note, 'prod') note.AddPage(self.main1, u'Vendas') note.AddPage(self.main2, u'Gastos') note.AddPage(self.main3, u'Produtos') note.AddPage(self.main4, u'Desperdícios') button_exit = GenBitmapTextButton( self, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u'Sair', pos=(600, -1), style=wx.SIMPLE_BORDER) button_exit.Bind(wx.EVT_BUTTON, self.exit) box.Add(note, 1, wx.EXPAND | wx.ALL, 5) box.Add(button_exit, 0, wx.ALL | wx.ALIGN_RIGHT, 15) self.SetSizer(box) note.SetSelection(sheet_to_focus - 1) self.Centre() self.Show()
def InitColours(self): """ Needed for correct background coloration """ GenBitmapTextButton.InitColours(self) if self.background_parent: self.faceDnClr = self.background_parent.GetBackgroundColour() else: self.faceDnClr = self.GetParent().GetBackgroundColour()
def CreateGenButton(parent, id, bmp, text=None, tooltip=None, colour=None, font=None): """ Create a bitmap button. """ if text is None: button = GenBitmapButton(parent, id, bmp, style=wx.SIMPLE_BORDER) else: button = GenBitmapTextButton(parent, id, bmp, text, style=wx.SIMPLE_BORDER) if font: button.SetFont(font) if tooltip is not None: button.SetToolTipString(tooltip) if colour is not None: button.SetBackgroundColour(colour) button.SetBezelWidth(0) button.SetUseFocusIndicator(False) return button
def __init__(self, parent): super().__init__(parent=parent) self.parent = parent self.surname = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.name = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.address = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.mail = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.phone = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.mobile = wx.TextCtrl(self, style=wx.ALIGN_LEFT) self.btn_save = GenBitmapTextButton( self, wx.ID_ANY, wx.Bitmap("%ssave.png" % IMG_PATH), 'Save'.rjust(20), size=(200, 45)) self.btn_quit = GenBitmapTextButton( self, wx.ID_ANY, wx.Bitmap("%sexit.png" % IMG_PATH), 'Exit'.rjust(20), size=(200, 45)) for button in (self.btn_save, self.btn_quit): button.SetBezelWidth(1) button.SetBackgroundColour(BTN_BG) self.btn_save.Disable() # sizer sizer = wx.FlexGridSizer(rows=7, cols=2, hgap=5, vgap=1) sizer.Add(wx.StaticText(self, -1, 'Surname*', style=wx.ALIGN_LEFT)) sizer.Add(self.surname, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Name*', style=wx.ALIGN_LEFT)) sizer.Add(self.name, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Address', style=wx.ALIGN_LEFT)) sizer.Add(self.address, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Mail', style=wx.ALIGN_LEFT)) sizer.Add(self.mail, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Phone', style=wx.ALIGN_LEFT)) sizer.Add(self.phone, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Mobile*', style=wx.ALIGN_LEFT)) sizer.Add(self.mobile, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_save, 0, wx.EXPAND | wx.ALL, 1) sizer.Add(self.btn_quit, 0, wx.EXPAND | wx.ALL, 1) sizer.AddGrowableCol(1) self.SetSizer(sizer)
def __init__(self, parent): super().__init__(parent=parent) self.parent = parent self.contacts = wx.ComboBox(self, -1, "", choices=[], style=wx.CB_DROPDOWN) self.surname = wx.StaticText(self) self.name = wx.StaticText(self) self.btn_delete = GenBitmapTextButton(self, wx.ID_ANY, wx.Bitmap("%strash.png" % IMG_PATH), 'Delete'.rjust(20), size=(150, -1)) self.btn_quit = GenBitmapTextButton(self, wx.ID_ANY, wx.Bitmap("%sexit.png" % IMG_PATH), 'Exit'.rjust(20), size=(150, -1)) for button in (self.btn_delete, self.btn_quit): button.SetBezelWidth(1) button.SetBackgroundColour(BTN_BG) self.btn_delete.Disable() # Sizer sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=5, vgap=1) sizer.Add(wx.StaticText(self, -1, 'Surname', style=wx.ALIGN_LEFT)) sizer.Add(self.surname, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(wx.StaticText(self, -1, 'Name', style=wx.ALIGN_LEFT)) sizer.Add(self.name, 0, wx.EXPAND | wx.ALL, 4) sizer.Add(self.btn_delete, 0, wx.EXPAND | wx.ALL, 1) sizer.Add(self.btn_quit, 0, wx.EXPAND | wx.ALL, 1) sizer.AddGrowableCol(1) outer_sizer = wx.BoxSizer(wx.VERTICAL) outer_sizer.Add(self.contacts, 0, wx.EXPAND | wx.ALL, 5) outer_sizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 5) self.SetSizer(outer_sizer)
def data_editor_enable(self, event): self.item = self.list_update.GetFocusedItem() if not self.item == -1: amount, unit = self.list_update.GetItemText(self.item, 2).split() self.textbox_product_description.SetValue( self.list_update.GetItemText(self.item, 1)) self.textbox_product_id.SetValue( str(self.list_update.GetItemData(self.item))) self.textbox_product_price.SetValue( self.list_update.GetItemText(self.item, 3)) self.textbox_product_amount.SetValue(amount) self.textbox_product_unit.SetValue(unit) self.__panel_product.Destroy() self.__panel_product = wx.Panel(self.panel_product_data, size=(200, 40), pos=(200, 210), style=wx.SIMPLE_BORDER) eplus = GenBitmapTextButton( self.__panel_product, 220, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u"Salvar", pos=(0, 0), size=(100, 40)) eplus.Bind(wx.EVT_BUTTON, self.data_edit) eremov = GenBitmapTextButton( self.__panel_product, 222, wx.Bitmap(core.directory_paths['icons'] + 'Cancel.png', wx.BITMAP_TYPE_PNG), u'Cancelar', pos=(100, 0), size=(100, 40)) eremov.Bind(wx.EVT_BUTTON, self.data_editor_disable)
def __init__(self, parent): super().__init__(parent=parent) self.parent = parent letters = [chr(i).upper() for i in range(ord('a'), ord('z') + 1)] self.pos = 5 for letter in letters: button = wx.Button(self, wx.ID_ANY, letter, (self.pos, 3), (26, 30)) button.SetBackgroundColour(BTN_BG) self.pos += 26 wx.StaticLine(self, wx.ID_ANY, (0, 35), (700, 3)) self.list_ctrl = wx.ListCtrl( self, wx.ID_ANY, (0, 50), (690, 200), wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) self.list_ctrl.InsertColumn(0, "Surname", wx.LIST_FORMAT_LEFT, 100) self.list_ctrl.InsertColumn(1, "Name", wx.LIST_FORMAT_LEFT, 100) self.list_ctrl.InsertColumn(2, "Address", wx.LIST_FORMAT_LEFT, 150) self.list_ctrl.InsertColumn(3, "mail", wx.LIST_FORMAT_LEFT, 150) self.list_ctrl.InsertColumn(4, "phone", wx.LIST_FORMAT_LEFT, 100) self.list_ctrl.InsertColumn(5, "mobile", wx.LIST_FORMAT_LEFT, 100) wx.StaticLine(self, wx.ID_ANY, (0, 270), (700, 3)) self.btn_delete = GenBitmapTextButton( self, wx.ID_ANY, wx.Bitmap("%strash.png" % IMG_PATH), 'Delete'.rjust(20), (10, 300), (340, -1)) self.btn_quit = GenBitmapTextButton(self, wx.ID_ANY, wx.Bitmap("%sexit.png" % IMG_PATH), 'Exit'.rjust(20), (345, 300), (340, -1)) for button in (self.btn_delete, self.btn_quit): button.SetBezelWidth(1) button.SetBackgroundColour(BTN_BG) self.btn_delete.Disable()
def setup_gui(self): self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.SetIcon(wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO)) panel_deliveries = wx.Panel(self, -1, size=(730, 380), pos=(10, 10), style=wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL) panel_deliveries.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.list_deliveries = wx.gizmos.TreeListCtrl(panel_deliveries, -1, pos=(10, 10), size=(710, 360), style=wx.SIMPLE_BORDER | wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT) self.list_deliveries.AddColumn(u"Data", width=120) self.list_deliveries.AddColumn(u"Horário", width=120) self.list_deliveries.AddColumn(u"Endereço", width=300) self.list_deliveries.AddColumn(u"Para", width=160) self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.open_view_sale, self.list_deliveries) panel_right = wx.Panel(self, -1, size=(200, 380), pos=(750, 10), style=wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL) panel_right.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) show_options = [u'Apenas entregas ativas', u'Todas as entregas cadastradas'] self.combobox_show_option = wx.ComboBox(panel_right, choices=show_options, size=(190, -1), pos=(2, 20), style=wx.CB_READONLY | wx.TE_MULTILINE) self.combobox_show_option.SetValue(show_options[0]) self.combobox_show_option.Bind(wx.EVT_COMBOBOX, self.setup) maps = wx.BitmapButton(panel_right, -1, wx.Bitmap(core.directory_paths['icons'] + 'map_icon_48.png'), pos=(76, 76), size=(48, 48), style=wx.NO_BORDER) maps.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) maps.Bind(wx.EVT_BUTTON, self.open_maps) tell = wx.Button(panel_right, -1, u'Mostrar mais', pos=(50, 150), size=(100, 30)) tell.Bind(wx.EVT_BUTTON, self.open_view_sale) panel_side_buttons = wx.Panel(panel_right, pos=(40, 220), size=(120, 120), style=wx.SIMPLE_BORDER) change_delivery_status = GenBitmapTextButton(panel_side_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Delivery.png'), u"Realizada", pos=(0, 0), size=(120, 40)) change_delivery_status.Bind(wx.EVT_BUTTON, self.change_delivery_status) up = GenBitmapTextButton(panel_side_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png'), u"Atualizar", pos=(0, 40), size=(120, 40)) up.Bind(wx.EVT_BUTTON, self.setup) down = GenBitmapTextButton(panel_side_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png'), u'Sair', pos=(0, 80), size=(120, 40)) down.Bind(wx.EVT_BUTTON, self.exit)
def data_editor_disable(self, event): self.textbox_product_unit.Clear() self.textbox_product_amount.Clear() self.textbox_product_price.Clear() self.textbox_product_id.Clear() self.textbox_product_description.Clear() self.__panel_product.Destroy() self.__panel_product = wx.Panel(self.panel_product_data, size=(300, 40), pos=(100, 210), style=wx.SIMPLE_BORDER) button_add_product = GenBitmapTextButton( self.__panel_product, 220, wx.Bitmap(core.directory_paths['icons'] + 'Add.png', wx.BITMAP_TYPE_PNG), u"Adicionar", pos=(0, 0), size=(100, 40)) button_add_product.Bind(wx.EVT_BUTTON, self.data_insert, id=220) button_product_editor = GenBitmapTextButton( self.__panel_product, 221, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u'Editar', pos=(100, 0), size=(100, 40)) button_product_editor.Bind(wx.EVT_BUTTON, self.data_editor_enable, id=221) button_remove_product = GenBitmapTextButton( self.__panel_product, 222, wx.Bitmap(core.directory_paths['icons'] + 'Trash.png', wx.BITMAP_TYPE_PNG), u'Apagar', pos=(200, 0), size=(100, 40)) button_remove_product.Bind(wx.EVT_BUTTON, self.data_delete, id=222)
def setup_gui(self): self.SetIcon(wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO)) self.Centre() self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) panel_original = wx.Panel(self, -1, size=(730, 380), pos=(10, 10), style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) self.list_edited_data = wx.gizmos.TreeListCtrl( panel_original, -1, pos=(10, 10), size=(710, 360), style=wx.SIMPLE_BORDER | wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT) self.list_edited_data.AddColumn(u"Horário", width=120) self.list_edited_data.AddColumn(u"ID", width=95) self.list_edited_data.AddColumn(u"Descrição", width=210) self.list_edited_data.AddColumn(u"Quantidade", width=90) self.list_edited_data.AddColumn(u"Valor", width=100) self.list_edited_data.SetMainColumn(0) self.list_edited_data.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.process_click) self.panel_control = wx.Panel(self, -1, size=(240, 380), pos=(750, 10), style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) wx.StaticText(self.panel_control, -1, u"Registros de", pos=(5, 80)) see = GenBitmapTextButton( self.panel_control, -1, wx.Bitmap(core.directory_paths['icons'] + 'Report.png', wx.BITMAP_TYPE_PNG), u"Ver mais sobre o registro", pos=(5, 180), size=(230, 50), style=wx.SIMPLE_BORDER) see.Bind(wx.EVT_BUTTON, self.process_click) rec = GenBitmapTextButton( self.panel_control, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png', wx.BITMAP_TYPE_PNG), u"Recuperar registro", pos=(5, 230), size=(230, 50), style=wx.SIMPLE_BORDER) rec.Bind(wx.EVT_BUTTON, self.ask_remove)
def SetForegroundColour(self, colour): """Override. Apply fg colour to both the image and the text. :param colour: (wx.Colour) """ current = self.GetForegroundColour() try: bmp = self.GetBitmapLabel() img = bmp.ConvertToImage() ColorizeImage(img, current, colour) self.SetBitmapLabel(wx.Bitmap(img)) except: logging.debug('SetForegroundColour not applied to image' 'for button {:s}'.format(self.GetName())) GenBitmapTextButton.SetForegroundColour(self, colour)
def __init__(self, *args, **kw): self.wxobj = args[0] self.verbose = self.wxobj.verbose from wx.lib.buttons import GenBitmapTextButton bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, (16, 16)) wx.Dialog.__init__(self, None, title="Dataset Dialog") self.ID_DONE = wx.NewId() self.SetSize((900, 800)) self.SetTitle("Please select files for the second condition.") mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(mainSizer) warningText = """ The Genetic Interactions method requires a total of four sets of datasets. Typically these are 2 strain backgrounds (e.g. Wildtype and Knockout) each grown under two conditions (e.g. in vitro and in vivo, or rich-media and presence of antibiotic). The Control and Experimental datasets added in the main TRANSIT interface are assumed to be the two strain backgrounds grown under the first condition. This interface allows you to add the remaining datasets for the second condition. """ warningStaticBox = wx.StaticText(self, wx.ID_ANY, warningText, (-1,-1), (-1, -1), wx.EXPAND) warningStaticBox.Wrap(800) mainSizer.Add(warningStaticBox, flag=wx.CENTER, border=5) # CONTROL ctrlSizerB = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Control Samples - Condition B" ), wx.VERTICAL ) bSizer2 = wx.BoxSizer( wx.HORIZONTAL ) self.ctrlRemoveButton = wx.Button( self, wx.ID_ANY, u"Remove", wx.DefaultPosition, (96,-1), 0 ) bSizer2.Add( self.ctrlRemoveButton, 0, wx.ALL, 5 ) self.ctrlView = wx.Button( self, wx.ID_ANY, u"Track View", wx.DefaultPosition, wx.DefaultSize, 0 ) self.ctrlView.Hide() bSizer2.Add( self.ctrlView, 0, wx.ALL, 5 ) self.ctrlScatter = wx.Button( self, wx.ID_ANY, u"Scatter", wx.DefaultPosition, wx.DefaultSize, 0 ) self.ctrlScatter.Hide() bSizer2.Add( self.ctrlScatter, 0, wx.ALL, 5 ) self.ctrlFilePicker = GenBitmapTextButton(self, 1, bmp, '[Click to add Control Dataset(s)]', size= wx.Size(500, -1)) bSizer2.Add( self.ctrlFilePicker, 1, wx.ALIGN_CENTER_VERTICAL, 5 ) ctrlSizerB.Add( bSizer2, 0, wx.EXPAND, 5 ) self.list_ctrl = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER ) self.list_ctrl.SetMaxSize(wx.Size(940,200)) ctrlSizerB.Add( self.list_ctrl, 1, wx.ALL|wx.EXPAND, 5 ) # EXPERIMENTAL expSizerB = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Experimental Samples - Condition B" ), wx.VERTICAL ) bSizer3 = wx.BoxSizer( wx.HORIZONTAL ) self.expRemoveButton = wx.Button( self, wx.ID_ANY, u"Remove", wx.DefaultPosition, (96,-1), 0 ) bSizer3.Add( self.expRemoveButton, 0, wx.ALL, 5 ) self.expView = wx.Button( self, wx.ID_ANY, u"Track View", wx.DefaultPosition, wx.DefaultSize, 0 ) self.expView.Hide() bSizer3.Add( self.expView, 0, wx.ALL, 5 ) self.expScatter = wx.Button( self, wx.ID_ANY, u"Scatter", wx.DefaultPosition, wx.DefaultSize, 0 ) self.expScatter.Hide() bSizer3.Add( self.expScatter, 0, wx.ALL, 5 ) self.expFilePicker = GenBitmapTextButton(self, 1, bmp, '[Click to add Experimental Dataset(s)]', size= wx.Size(500, -1)) bSizer3.Add( self.expFilePicker, 1, wx.ALIGN_CENTER_VERTICAL, 5 ) expSizerB.Add( bSizer3, 0, wx.EXPAND, 5 ) self.list_exp = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER ) self.list_exp.SetMaxSize(wx.Size(940, 200)) expSizerB.Add( self.list_exp, 1, wx.ALL|wx.EXPAND, 5 ) # MAIN mainSizer.Add( ctrlSizerB, 1, wx.EXPAND, 5 ) mainSizer.Add( expSizerB, 1, wx.EXPAND, 5 ) button_sizer = wx.BoxSizer(wx.HORIZONTAL) doneButton = wx.Button(self, self.ID_DONE, label='Done') cancelButton = wx.Button(self, wx.ID_CANCEL, label='Cancel') button_sizer.Add(doneButton, flag=wx.LEFT, border=5) button_sizer.Add(cancelButton, flag=wx.LEFT, border=5) self.expFilePicker.Bind( wx.EVT_BUTTON, self.loadExpFileFunc ) self.ctrlFilePicker.Bind( wx.EVT_BUTTON, self.loadCtrlFileFunc ) mainSizer.Add(button_sizer, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10) doneButton.Bind(wx.EVT_BUTTON, self.OnClose) cancelButton.Bind(wx.EVT_BUTTON, self.OnClose) self.ctrlFilePicker.Bind( wx.EVT_BUTTON, self.loadCtrlFileFunc ) self.expFilePicker.Bind( wx.EVT_BUTTON, self.loadExpFileFunc ) self.ctrlRemoveButton.Bind( wx.EVT_BUTTON, self.ctrlRemoveFunc ) self.expRemoveButton.Bind( wx.EVT_BUTTON, self.expRemoveFunc ) self.index_ctrl = 0 self.list_ctrl.InsertColumn(0, 'File', width=210) self.list_ctrl.InsertColumn(1, 'Total Reads', width=85) self.list_ctrl.InsertColumn(2, 'Density', width=85) self.list_ctrl.InsertColumn(3, 'Mean Count', width=90) self.list_ctrl.InsertColumn(4, 'Max Count', width=85) self.list_ctrl.InsertColumn(5, 'Full Path', width=403) self.index_exp = 0 self.list_exp.InsertColumn(0, 'File', width=210) self.list_exp.InsertColumn(1, 'Total Reads', width=85) self.list_exp.InsertColumn(2, 'Density', width=85) self.list_exp.InsertColumn(3, 'Mean Count', width=90) self.list_exp.InsertColumn(4, 'Max Count', width=85) self.list_exp.InsertColumn(5, 'Full Path',width=403)
def SetLabel(self, label): GenBitmapTextButton.SetLabel(self, label) # FIXME: should be fixed into GenBitmapTextButton => opened ticket # #15032 # http://trac.wxwidgets.org/ticket/15032 self.Refresh() # force to redraw the image
def setup_gui(self): self.Centre() self.SetIcon(wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO)) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) # first first = wx.Panel(self, -1, size=(495, 250), pos=(10, 10), style=wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL) first.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) wx.StaticText(first, -1, u"Descrição: *", pos=(20, 20)) self.textbox_description = wx.TextCtrl(first, -1, pos=(20, 40), size=(200, 30)) wx.StaticText(first, -1, u"Categoria:", pos=(20, 90)) self.combobox_category = wx.ComboBox(first, -1, pos=(20, 110), size=(165, 30), style=wx.CB_READONLY) self.update_categories() button_category = wx.BitmapButton( first, -1, wx.Bitmap(core.directory_paths['icons'] + 'Add.png', wx.BITMAP_TYPE_PNG), pos=(185, 105), size=(32, 32), style=wx.NO_BORDER) button_category.Bind(wx.EVT_BUTTON, self.open_category_register) button_category.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) wx.StaticText(first, -1, u"Valor: *", pos=(20, 160)) self.textbox_value = wx.TextCtrl(first, -1, pos=(20, 180), size=(200, 30)) self.textbox_value.Bind(wx.EVT_CHAR, core.check_currency) self.textbox_value.SetValue(u'R$ 0,00') wx.StaticText(first, -1, u"Data da Transação: *", pos=(240, 35)) self.calendar_date = wx.calendar.CalendarCtrl( first, -1, wx.DateTime_Now(), pos=(240, 55), style=wx.calendar.CAL_SHOW_HOLIDAYS | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION | wx.calendar.CAL_BORDER_ROUND | wx.SIMPLE_BORDER) self.checkbox_payed = wx.CheckBox(first, -1, u'Pagamento Realizado? ', pos=(200, 220), size=(-1, -1), style=wx.ALIGN_LEFT) self.checkbox_payed.SetFont(wx.Font(-1, wx.SWISS, wx.NORMAL, wx.BOLD)) self.Bind(wx.EVT_CHECKBOX, self.checkbox_change, self.checkbox_payed) self.checkbox_payed.SetForegroundColour(wx.BLUE) self.checkbox_payed.SetValue(True) self.checkbox_payed.SetSize((160, -1)) # last last = wx.Panel(self, -1, size=(130, 250), pos=(515, 10), style=wx.SIMPLE_BORDER) last.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) if self.editable: last_ = wx.Panel(last, pos=(5, 65), size=(120, 120), style=wx.SIMPLE_BORDER) finish = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Check.png', wx.BITMAP_TYPE_PNG), u'Finalizar', pos=(0, 0), size=(120, 40)) finish.Bind(wx.EVT_BUTTON, self.ask_end) restart = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png', wx.BITMAP_TYPE_PNG), u'Recomeçar', pos=(0, 40), size=(120, 40)) restart.Bind(wx.EVT_BUTTON, self.ask_clean) cancel = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u"sair", pos=(0, 80), size=(120, 40)) cancel.Bind(wx.EVT_BUTTON, self.ask_exit) else: self.textbox_description.Disable() self.textbox_value.Disable() self.combobox_category.Disable() self.calendar_date.Disable() self.checkbox_payed.Disable() last_ = wx.Panel(last, pos=(5, 85), size=(120, 80), style=wx.SIMPLE_BORDER) edit = GenBitmapTextButton( last_, 243, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u"Editar", pos=(0, 0), size=(120, 40)) edit.Bind(wx.EVT_BUTTON, self.open_transaction_edit) cancel = GenBitmapTextButton( last_, 242, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u"Sair", pos=(0, 40), size=(120, 40)) cancel.Bind(wx.EVT_BUTTON, self.exit)
def setup_gui(self): self.SetPosition(wx.Point(100, 100)) self.SetSize(wx.Size(1140, 560)) self.SetIcon((wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO))) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) panel_top = wx.Panel(self, pos=(10, 10), size=(1120, 100)) button_categories = GenBitmapTextButton( panel_top, -1, wx.Bitmap(core.directory_paths['icons'] + 'Drawer.png', wx.BITMAP_TYPE_PNG), u'Categorias', pos=(5, 40), size=(115, 40), style=wx.SIMPLE_BORDER) button_categories.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) button_categories.Bind(wx.EVT_BUTTON, self.open_category_manager) button_payment = GenBitmapTextButton( panel_top, -1, wx.Bitmap(core.directory_paths['icons'] + 'Check.png', wx.BITMAP_TYPE_PNG), u'Pagamento Realizado', pos=(140, 40), size=(160, 40), style=wx.SIMPLE_BORDER) button_payment.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) button_payment.Bind(wx.EVT_BUTTON, self.data_edit_payment) panel_buttons_left = wx.Panel(panel_top, pos=(320, 40), size=(400, 40), style=wx.SIMPLE_BORDER) see = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Search.png', wx.BITMAP_TYPE_PNG), u'Ver Mais', pos=(0, 0), size=(100, 40)) see.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) see.Bind(wx.EVT_BUTTON, self.data_open) plus = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'contact-new.png', wx.BITMAP_TYPE_PNG), u'Novo', pos=(100, 0), size=(100, 40)) plus.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) plus.Bind(wx.EVT_BUTTON, self.open_new_transaction) edi = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u'Editar', pos=(200, 0), size=(100, 40)) edi.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) edi.Bind(wx.EVT_BUTTON, self.data_edit) era = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Trash.png', wx.BITMAP_TYPE_PNG), u'Apagar', pos=(300, 0), size=(100, 40)) era.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) era.Bind(wx.EVT_BUTTON, self.ask_delete) self.combobox_month_displayed = wx.ComboBox(panel_top, -1, pos=(745, 45), size=(100, 30), style=wx.CB_READONLY) self.combobox_month_displayed.Bind(wx.EVT_TEXT_ENTER, self.setup) panel_buttons_right = wx.Panel(panel_top, pos=(870, 40), size=(240, 40), style=wx.SIMPLE_BORDER) quir = GenBitmapTextButton(panel_buttons_right, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png'), u'Sair', pos=(120, 0), size=(120, 40)) quir.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) quir.Bind(wx.EVT_BUTTON, self.exit) rep = GenBitmapTextButton(panel_buttons_right, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png'), u'Atualizar', pos=(0, 0), size=(120, 40)) rep.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) rep.Bind(wx.EVT_BUTTON, self.setup) self.notebook_lists = wx.Notebook(self, -1, pos=(15, 110), size=(1110, 410)) self.notebook_lists.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) for i in range(2): list_transactions = wx.ListCtrl(self.notebook_lists, -1, style=wx.LC_VRULES | wx.LC_HRULES | wx.SIMPLE_BORDER | wx.LC_REPORT) list_transactions.InsertColumn(0, u'Descrição', width=400) list_transactions.InsertColumn(1, u'ID', width=90) list_transactions.InsertColumn(2, u'Categoria', width=250) list_transactions.InsertColumn(3, u'Valor', width=110) list_transactions.InsertColumn(4, u'Data', width=120) list_transactions.InsertColumn(5, u'Pagamento', width=130) list_transactions.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.data_open) if not i: self.list_expenses = list_transactions text = u'Contas e Gastos' else: self.list_incomes = list_transactions text = u'Ganhos e Entradas' self.notebook_lists.AddPage(list_transactions, text)
def setup_gui(self): self.Centre() self.SetIcon(wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO)) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) # first first = wx.Panel(self, -1, size=(450, 230), pos=(10, 10), style=wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL) first.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.textbox_description = wx.SearchCtrl(first, -1, pos=(10, 10), size=(430, 30)) self.textbox_description.Bind(wx.EVT_TEXT, self.database_search) self.textbox_description.ShowSearchButton(True) self.textbox_description.SetDescriptiveText(u'Busca de produto') self.list_inventory = wx.ListCtrl(first, -1, pos=(10, 45), size=(430, 115), style=wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.SIMPLE_BORDER) self.list_inventory.InsertColumn(0, u'Descrição', width=230) self.list_inventory.InsertColumn(1, u'Estoque') self.list_inventory.InsertColumn(2, u'Preço') self.list_inventory.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.database_select) wx.StaticText(first, -1, u"ID: *", pos=(50, 170)) self.textbox_id = wx.TextCtrl(first, -1, pos=(50, 190), size=(150, 30)) self.textbox_id.Bind(wx.EVT_CHAR, core.check_number) wx.StaticText(first, -1, u"Quantidade: *", pos=(250, 170)) self.textbox_amount = wx.TextCtrl(first, -1, pos=(250, 190), size=(150, 30)) self.textbox_product_unit = wx.TextCtrl(first, -1, pos=(405, 195), size=(30, -1), style=wx.NO_BORDER | wx.TE_READONLY) self.textbox_product_unit.SetBackgroundColour( core.COLOR_DEFAULT_BACKGROUND) # last last = wx.Panel(self, -1, size=(140, 230), pos=(470, 10), style=wx.SIMPLE_BORDER) last.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) last_ = wx.Panel(last, pos=(10, 55), size=(120, 120), style=wx.SIMPLE_BORDER) finish = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Check.png', wx.BITMAP_TYPE_PNG), u'Finalizar', pos=(0, 0), size=(120, 40)) finish.Bind(wx.EVT_BUTTON, self.ask_end) restart = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png', wx.BITMAP_TYPE_PNG), u'Recomeçar', pos=(0, 40), size=(120, 40)) restart.Bind(wx.EVT_BUTTON, self.ask_clean) cancel = GenBitmapTextButton( last_, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u"sair", pos=(0, 80), size=(120, 40)) cancel.Bind(wx.EVT_BUTTON, self.ask_exit)
def setup_gui(self): self.SetIcon((wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO))) self.Centre() self.list_update = wx.ListCtrl(self, -1, pos=(10, 280), size=(450, 275), style=wx.LC_REPORT | wx.SIMPLE_BORDER | wx.LC_VRULES | wx.LC_HRULES) self.list_update.InsertColumn(0, u"ID", width=50) self.list_update.InsertColumn(1, u"Descrição", width=180) self.list_update.InsertColumn(2, u"Quantidade") self.list_update.InsertColumn(3, u"Preço Unit.") self.radio_update = wx.RadioButton(self, -1, label=u'Atualizar estoque', pos=(10, 560), size=(225, 25), style=wx.SIMPLE_BORDER) self.radio_entry = wx.RadioButton(self, -1, label=u'Entrada de produtos', pos=(235, 560), size=(225, 25), style=wx.SIMPLE_BORDER) self.radio_update.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) self.radio_entry.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) self.radio_update.SetToolTip( wx.ToolTip(u'Dar uma nova quantidade em estoque para os produtos.' u'\nIgnora um estoque anterior.')) self.radio_entry.SetToolTip( wx.ToolTip( u'Atualiza o estoque de acordo com uma entrada de produtos.' u'\nApenas registra uma variação no estoque.')) self.radio_entry.SetValue(True) # product self.panel_product_data = wx.Panel(self, 22, pos=(10, 10), size=(450, 260), style=wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL) self.panel_product_data.SetBackgroundColour( core.COLOR_DEFAULT_BACKGROUND) fin = wx.BitmapButton(self.panel_product_data, -1, wx.Bitmap(core.directory_paths['icons'] + 'Add.png'), pos=(408, 10), size=(32, 32), style=wx.NO_BORDER) fin.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) fin.Bind(wx.EVT_BUTTON, self.open_product_register) self.textbox_product_description = wx.SearchCtrl( self.panel_product_data, 223, pos=(10, 10), size=(395, 32)) self.textbox_product_description.Bind(wx.EVT_TEXT, self.database_search, id=223) self.textbox_product_description.ShowSearchButton(False) self.textbox_product_description.SetDescriptiveText( u'Descrição do produto') self.list_inventory = wx.ListCtrl(self.panel_product_data, -1, pos=(10, 45), size=(430, 115), style=wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.SIMPLE_BORDER) self.list_inventory.InsertColumn(0, u'Descrição', width=230) self.list_inventory.InsertColumn(1, u'Estoque') self.list_inventory.InsertColumn(2, u'Preço') self.list_inventory.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.database_select) self.textbox_product_id = wx.SearchCtrl(self.panel_product_data, -1, pos=(10, 170), size=(100, -1)) self.textbox_product_id.ShowSearchButton(False) self.textbox_product_id.SetDescriptiveText(u'ID') self.textbox_product_price = wx.SearchCtrl(self.panel_product_data, -1, pos=(130, 170), size=(80, -1)) self.textbox_product_price.ShowSearchButton(False) self.textbox_product_price.SetDescriptiveText(u'Preço') self.textbox_product_price.SetValue(u'R$ 0,00') self.textbox_product_price.Disable() self.textbox_product_amount = wx.SearchCtrl(self.panel_product_data, -1, pos=(230, 170), size=(100, -1)) self.textbox_product_amount.ShowSearchButton(False) self.textbox_product_amount.SetDescriptiveText(u'Quantidade') self.textbox_product_unit = wx.TextCtrl(self.panel_product_data, -1, pos=(335, 175), size=(50, -1), style=wx.NO_BORDER | wx.TE_READONLY) self.textbox_product_unit.SetBackgroundColour( core.COLOR_DEFAULT_BACKGROUND) self.__panel_product = wx.Panel(self.panel_product_data, size=(300, 40), pos=(100, 210), style=wx.SIMPLE_BORDER) button_add_product = GenBitmapTextButton( self.__panel_product, 220, wx.Bitmap(core.directory_paths['icons'] + 'Add.png', wx.BITMAP_TYPE_PNG), u"Adicionar", pos=(0, 0), size=(100, 40)) button_add_product.Bind(wx.EVT_BUTTON, self.data_insert, id=220) button_product_editor = GenBitmapTextButton( self.__panel_product, 221, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u'Editar', pos=(100, 0), size=(100, 40)) button_product_editor.Bind(wx.EVT_BUTTON, self.data_editor_enable, id=221) button_remove_product = GenBitmapTextButton( self.__panel_product, 222, wx.Bitmap(core.directory_paths['icons'] + 'Trash.png', wx.BITMAP_TYPE_PNG), u'Apagar', pos=(200, 0), size=(100, 40)) button_remove_product.Bind(wx.EVT_BUTTON, self.data_delete, id=222) bottom = wx.Panel(self, -1, size=(450, 50), pos=(10, 590), style=wx.SIMPLE_BORDER) add = GenBitmapTextButton( bottom, -1, wx.Bitmap(core.directory_paths['icons'] + 'Add.png', wx.BITMAP_TYPE_PNG), u'Registrar produtos', size=(200, 50), pos=(0, 0)) reset = GenBitmapTextButton( bottom, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png', wx.BITMAP_TYPE_PNG), u'Recomeçar', size=(125, 50), pos=(200, 0)) cancel = GenBitmapTextButton( bottom, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u'Sair', size=(125, 50), pos=(325, 0)) add.Bind(wx.EVT_BUTTON, self.ask_end) reset.Bind(wx.EVT_BUTTON, self.ask_clean) cancel.Bind(wx.EVT_BUTTON, self.ask_exit) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND)
def setup_gui(self): self.SetPosition(wx.Point(100, 100)) self.SetSize(wx.Size(1200, 550)) self.SetIcon((wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO))) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) panel_top = wx.Panel(self, pos=(10, 10), size=(1180, 100)) button_categories = GenBitmapTextButton( panel_top, -1, wx.Bitmap(core.directory_paths['icons'] + 'Drawer.png', wx.BITMAP_TYPE_PNG), u'Categorias', pos=(5, 40), size=(115, 40), style=wx.SIMPLE_BORDER) button_categories.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) button_categories.Bind(wx.EVT_BUTTON, self.open_category_manager) panel_buttons_left = wx.Panel(panel_top, pos=(140, 40), size=(500, 40), style=wx.SIMPLE_BORDER) see = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Search.png', wx.BITMAP_TYPE_PNG), u'Ver Mais', pos=(0, 0), size=(100, 40)) see.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) see.Bind(wx.EVT_BUTTON, self.data_open) plus = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'contact-new.png', wx.BITMAP_TYPE_PNG), u'Novo', pos=(100, 0), size=(100, 40)) plus.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) plus.Bind(wx.EVT_BUTTON, self.open_new_product) mplus = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Box_download.png', wx.BITMAP_TYPE_PNG), u'Entrada', pos=(200, 0), size=(100, 40)) mplus.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) mplus.Bind(wx.EVT_BUTTON, self.open_update_inventory) edi = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u'Editar', pos=(300, 0), size=(100, 40)) edi.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) edi.Bind(wx.EVT_BUTTON, self.data_edit) era = GenBitmapTextButton( panel_buttons_left, -1, wx.Bitmap(core.directory_paths['icons'] + 'Trash.png', wx.BITMAP_TYPE_PNG), u'Apagar', pos=(400, 0), size=(100, 40)) era.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) era.Bind(wx.EVT_BUTTON, self.ask_delete) self.textbox_filter = wx.SearchCtrl(panel_top, -1, pos=(665, 45), size=(200, 30), style=wx.TE_PROCESS_ENTER) self.textbox_filter.SetDescriptiveText(u'Busca por nome') self.textbox_filter.ShowCancelButton(True) fin = wx.BitmapButton(panel_top, -1, wx.Bitmap(core.directory_paths['icons'] + 'edit_find.png'), pos=(870, 42), size=(35, 35), style=wx.NO_BORDER) fin.Bind(wx.EVT_BUTTON, self.database_search) fin.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.textbox_filter.Bind(wx.EVT_TEXT_ENTER, self.database_search) self.textbox_filter.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.database_search) self.textbox_filter.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.clean) panel_buttons_right = wx.Panel(panel_top, pos=(930, 40), size=(240, 40), style=wx.SIMPLE_BORDER) quir = GenBitmapTextButton(panel_buttons_right, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png'), u'Sair', pos=(120, 0), size=(120, 40)) quir.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) quir.Bind(wx.EVT_BUTTON, self.exit) rep = GenBitmapTextButton(panel_buttons_right, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png'), u'Atualizar', pos=(0, 0), size=(120, 40)) rep.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) rep.Bind(wx.EVT_BUTTON, self.setup) panel_center = wx.Panel(self, -1, pos=(10, 110), size=(1180, 410)) self.list_products = wx.ListCtrl(panel_center, -1, pos=(5, 5), size=(1170, 390), style=wx.LC_VRULES | wx.LC_HRULES | wx.SIMPLE_BORDER | wx.LC_REPORT) self.list_products.InsertColumn(0, u'Descrição do produto', width=400) self.list_products.InsertColumn(1, u'ID', width=50) self.list_products.InsertColumn(2, u'Categoria', width=150) self.list_products.InsertColumn(3, u'Preço', width=200) self.list_products.InsertColumn(4, u'Estoque', width=180) self.list_products.InsertColumn(5, u'Vendidos', width=100) self.list_products.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.data_open)
def setup_gui(self): self.SetSize(wx.Size(500, 410)) self.SetIcon((wx.Icon(core.ICON_MAIN, wx.BITMAP_TYPE_ICO))) self.SetBackgroundColour(core.COLOR_DEFAULT_BACKGROUND) self.Centre() self.panel_data = wx.Panel(self, -1, pos=(0, 0), size=(500, 320), style=wx.TAB_TRAVERSAL) wx.StaticText(self.panel_data, -1, u'Descrição do produto:', pos=(190, 10)) wx.StaticText(self.panel_data, -1, u'Código de Barras:', pos=(190, 70)) wx.StaticText(self.panel_data, -1, u'Preço:', pos=(190, 130)) wx.StaticText(self.panel_data, -1, u'Estoque:', pos=(350, 130)) wx.StaticText(self.panel_data, -1, u'Categoria:', pos=(190, 190)) wx.StaticText(self.panel_data, -1, u'Fornecedor:', pos=(350, 190)) wx.StaticText(self.panel_data, -1, u'Observações:', pos=(10, 230)) self.textbox_description = wx.TextCtrl(self.panel_data, -1, pos=(190, 30), size=(300, 30)) self.textbox_barcode = wx.TextCtrl(self.panel_data, -1, pos=(190, 90), size=(300, 30)) self.textbox_price = wx.TextCtrl(self.panel_data, -1, pos=(190, 150), size=(100, 30)) self.textbox_amount = wx.TextCtrl(self.panel_data, -1, pos=(350, 150), size=(100, 30)) self.textbox_price.Bind(wx.EVT_CHAR, core.check_currency) self.textbox_barcode.Bind(wx.EVT_CHAR, core.check_number) if not self.editable: self.combobox_category = wx.TextCtrl(self.panel_data, -1, pos=(190, 210), size=(150, 30)) else: self.combobox_category = wx.ComboBox(self.panel_data, -1, pos=(190, 210), size=(150, 30), style=wx.TE_READONLY) self.textbox_supplier = wx.TextCtrl(self.panel_data, -1, pos=(350, 210), size=(140, 30)) self.textbox_observation = wx.TextCtrl(self.panel_data, -1, pos=(10, 250), size=(480, 65), style=wx.TE_MULTILINE) self.panel_image = wx.Panel(self.panel_data, -1, size=(150, 150), pos=(10, 45), style=wx.SIMPLE_BORDER) self.panel_image.SetBackgroundColour('#ffffff') wx.EVT_PAINT(self.panel_image, self.OnPaint) panel_bottom = wx.Panel(self, -1, pos=(0, 325), size=(500, 50)) if not self.editable: panel_bottom_buttons = wx.Panel(panel_bottom, pos=(150, 5), size=(200, 40), style=wx.SIMPLE_BORDER) edipo = GenBitmapTextButton( panel_bottom_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Edit.png', wx.BITMAP_TYPE_PNG), u"Editar", pos=(0, 0), size=(100, 40)) edipo.Bind(wx.EVT_BUTTON, self.set_editable) cancel = GenBitmapTextButton( panel_bottom_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u"Sair", pos=(100, 0), size=(100, 40)) cancel.Bind(wx.EVT_BUTTON, self.ask_exit) self.combobox_category.Disable() self.textbox_description.Disable() self.textbox_barcode.Disable() self.textbox_price.Disable() self.textbox_amount.Disable() self.textbox_supplier.Disable() self.textbox_observation.Disable() else: panel_bottom_buttons = wx.Panel(panel_bottom, pos=(90, 5), size=(320, 40), style=wx.SIMPLE_BORDER) finish = GenBitmapTextButton( panel_bottom_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Check.png', wx.BITMAP_TYPE_PNG), u"Finalizar", pos=(0, 0), size=(100, 40)) finish.Bind(wx.EVT_BUTTON, self.ask_end) restart = GenBitmapTextButton( panel_bottom_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Reset.png', wx.BITMAP_TYPE_PNG), u"Recomeçar", pos=(100, 0), size=(120, 40)) restart.Bind(wx.EVT_BUTTON, self.ask_clean) cancel = GenBitmapTextButton( panel_bottom_buttons, -1, wx.Bitmap(core.directory_paths['icons'] + 'Exit.png', wx.BITMAP_TYPE_PNG), u"Sair", pos=(220, 0), size=(100, 40)) cancel.Bind(wx.EVT_BUTTON, self.ask_exit) self.clean()
def __init__(self, parent): """Constructor""" self.panel = wx.Panel.__init__(self, parent=parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) compilerList = ['SDCC', 'XC8'] devicesList = [ '16f1459', '18f13k50', '18f14k50', '18f2455', '18f2550', '18f25k50', '18f26j50', '18f26j53', '18f27j53', '18f4455', '18f4550', '18f45k50', '18f46j50', '18f46j53', '18f47j53' ] oscillatorList = [ '4', '8', '12', '16', '20', '24', '40', '48', 'INTOSC' ] optionsList = [ "String Descriptor", "Low Speed USB", "Low Voltage Programming", "Ext. 32768Hz Oscillator", "Watchdog Enabled" ] buttonsList = [ ('img/runw.png', 'Compile the bootloader code source', self.OnCompile), ('img/board.png', 'Program (ICSP) the bootloader on the chip', self.OnProgram), ('img/open.png', 'Open a Hex file', self.OnOpen), ('img/dwn.png', 'Upload a Hex File on the Chip with the bootloader\'s help', self.OnUpload), ('img/help.png', 'Get some explanations', self.OnHelp), ('img/exit.png', 'Quit Wiztiti program', self.OnQuit) ] sizerList = [] # list of all sizers # -------------------------------------------------------------- # Compiler # -------------------------------------------------------------- CmpBox = wx.StaticBox(self, -1, label=u'Compiler ') boldfont = CmpBox.GetFont() boldfont.SetWeight(wx.BOLD) CmpBox.SetFont(boldfont) sizerList.append(wx.StaticBoxSizer(CmpBox, wx.VERTICAL)) # Create CheckBoxes for each supported processor old_col = 0 grid = [] grid.append(wx.BoxSizer(wx.HORIZONTAL)) self.checkboxCmpList = [] for i in range(len(compilerList)): # list of all checkboxes self.checkboxCmpList.append( wx.CheckBox(self, id=i, label=compilerList[i])) new_col = i / 5 if (new_col > old_col): old_col = new_col grid.append(wx.BoxSizer(wx.HORIZONTAL)) grid[-1].Add(self.checkboxCmpList[-1], 0, wx.ALL | wx.EXPAND, 5) for i in range(len(grid)): sizerList[-1].Add(grid[i], 0, wx.ALL | wx.EXPAND, 5) # -------------------------------------------------------------- # Microcontroller # -------------------------------------------------------------- DevBox = wx.StaticBox(self, -1, label=u'PIC Microcontroller Target ') boldfont = DevBox.GetFont() boldfont.SetWeight(wx.BOLD) DevBox.SetFont(boldfont) sizerList.append(wx.StaticBoxSizer(DevBox, wx.VERTICAL)) # Create CheckBoxes for each supported processor old_col = 0 grid = [] grid.append(wx.BoxSizer(wx.HORIZONTAL)) self.checkboxDevList = [] for i in range(len(devicesList)): # list of all checkboxes self.checkboxDevList.append( wx.CheckBox(self, id=i, label=devicesList[i])) new_col = i / 5 if (new_col > old_col): old_col = new_col grid.append(wx.BoxSizer(wx.HORIZONTAL)) grid[-1].Add(self.checkboxDevList[-1], 0, wx.ALL | wx.EXPAND, 5) for i in range(len(grid)): sizerList[-1].Add(grid[i], 0, wx.ALL | wx.EXPAND, 5) # -------------------------------------------------------------- # Oscillator # -------------------------------------------------------------- OscBox = wx.StaticBox(self, -1, label=u'Oscillator\'s Frequency (MHz)') boldfont = OscBox.GetFont() boldfont.SetWeight(wx.BOLD) OscBox.SetFont(boldfont) sizerList.append(wx.StaticBoxSizer(OscBox, wx.VERTICAL)) old_col = 0 grid = [] grid.append(wx.BoxSizer(wx.HORIZONTAL)) self.checkboxOscList = [] for i in range(len(oscillatorList)): # list of all checkboxes self.checkboxOscList.append( wx.CheckBox(self, id=i, label=oscillatorList[i])) new_col = i / 8 if (new_col > old_col): old_col = new_col grid.append(wx.BoxSizer(wx.HORIZONTAL)) grid[-1].Add(self.checkboxOscList[-1], 0, wx.ALL | wx.EXPAND, 5) for i in range(len(grid)): sizerList[-1].Add(grid[i], 0, wx.ALL | wx.EXPAND, 5) # -------------------------------------------------------------- # Options # -------------------------------------------------------------- OptBox = wx.StaticBox(self, -1, label=u'Options') boldfont = OptBox.GetFont() boldfont.SetWeight(wx.BOLD) OptBox.SetFont(boldfont) sizerList.append(wx.StaticBoxSizer(OptBox, wx.VERTICAL)) old_col = 0 grid = [] grid.append(wx.BoxSizer(wx.HORIZONTAL)) self.checkboxOptList = [] for i in range(len(optionsList)): # list of all checkboxes self.checkboxOptList.append( wx.CheckBox(self, id=i, label=optionsList[i])) new_col = i / 2 if (new_col > old_col): old_col = new_col grid.append(wx.BoxSizer(wx.HORIZONTAL)) grid[-1].Add(self.checkboxOptList[-1], 0, wx.ALL | wx.EXPAND, 5) for i in range(len(grid)): sizerList[-1].Add(grid[i], 0, wx.ALL | wx.EXPAND, 5) # -------------------------------------------------------------- # Buttons # -------------------------------------------------------------- ButBox = wx.StaticBox(self, -1, label=u'Actions') boldfont = OptBox.GetFont() boldfont.SetWeight(wx.BOLD) ButBox.SetFont(boldfont) sizerList.append(wx.StaticBoxSizer(ButBox, wx.VERTICAL)) old_col = 0 grid = [] grid.append(wx.BoxSizer(wx.HORIZONTAL)) self.butList = [] for i in range(len(buttonsList)): # list of all buttons img, lab, event = buttonsList[i] b = GenBitmapTextButton(self, i, wx.Bitmap(img), label="", size=(48, 48)) b.SetBezelWidth(1) b.SetBackgroundColour('#DDDDDD') #b.SetHelpText(lab) b.SetToolTipString(lab) # Catch events b.Bind(wx.EVT_BUTTON, event) b.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter) b.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave) self.butList.append(b) new_col = i / 6 if (new_col > old_col): old_col = new_col grid.append(wx.BoxSizer(wx.HORIZONTAL)) grid[-1].Add(self.butList[-1], 0, wx.ALL | wx.EXPAND, 5) for i in range(len(grid)): sizerList[-1].Add(grid[i], 0, wx.ALL | wx.EXPAND, 5) # -------------------------------------------------------------- # Sizer # -------------------------------------------------------------- topSizer = wx.BoxSizer(wx.VERTICAL) for i in range(len(sizerList)): topSizer.Add(sizerList[i], 0, wx.ALL | wx.EXPAND, 5) self.SetSizerAndFit(topSizer) self.Show(True)
def __init__(self): """ Initialize the dialog """ wx.Dialog.__init__(self, None, wx.ID_ANY, 'Preferences', size=(550, 400)) appPath = controller.appPath # Create widgets font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD) serverLbl = wx.StaticText(self, label="Update Server:") self.serverTxt = wx.TextCtrl(self) self.serverTxt.Disable() usernameLbl = wx.StaticText(self, label="Username:"******"Password:"******"Update Interval:") self.updateTxt = wx.TextCtrl(self) minutesLbl = wx.StaticText(self, label="minutes") agencyLbl = wx.StaticText(self, label="Agency Filter:") choices = [ "Include all agencies except", "Exclude all agencies except" ] self.agencyCbo = wx.ComboBox(self, value="Include all agencies except", choices=choices, style=wx.CB_DROPDOWN | wx.CB_READONLY) self.agencyCbo.SetFont(font) self.filterTxt = wx.TextCtrl(self, wx.ID_ANY, "") img = wx.Bitmap(r"%s/images/filesave.png" % appPath) saveBtn = GenBitmapTextButton(self, wx.ID_ANY, img, "Save", size=(110, 50)) saveBtn.Bind(wx.EVT_BUTTON, self.savePreferences) cancelBtn = CloseBtn(self, label="Cancel") cancelBtn.Bind(wx.EVT_BUTTON, self.onCancel) # Set the widgets font widgets = [ serverLbl, usernameLbl, passwordLbl, updateLbl, agencyLbl, minutesLbl, self.serverTxt, self.usernameTxt, self.passwordTxt, self.updateTxt, self.agencyCbo, self.filterTxt, saveBtn, cancelBtn ] for widget in widgets: widget.SetFont(font) # layout widgets mainSizer = wx.BoxSizer(wx.VERTICAL) updateSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) prefSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5) prefSizer.AddGrowableCol(1) prefSizer.Add(serverLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) prefSizer.Add(self.serverTxt, 0, wx.EXPAND) prefSizer.Add(usernameLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) prefSizer.Add(self.usernameTxt, 0, wx.EXPAND) prefSizer.Add(passwordLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) prefSizer.Add(self.passwordTxt, 0, wx.EXPAND) prefSizer.Add(updateLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) updateSizer.Add(self.updateTxt, 0, wx.RIGHT, 5) updateSizer.Add(minutesLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) prefSizer.Add(updateSizer) prefSizer.Add(agencyLbl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) prefSizer.Add(self.agencyCbo, 0, wx.EXPAND) prefSizer.Add((20, 20)) prefSizer.Add(self.filterTxt, 0, wx.EXPAND) mainSizer.Add(prefSizer, 0, wx.EXPAND | wx.ALL, 5) btnSizer.Add(saveBtn, 0, wx.ALL, 5) btnSizer.Add(cancelBtn, 0, wx.ALL, 5) mainSizer.Add(btnSizer, 0, wx.ALL | wx.ALIGN_RIGHT, 10) self.SetSizer(mainSizer) # load preferences self.loadPreferences()
class DatasetDialog(wx.Dialog): def __init__(self, *args, **kw): self.wxobj = args[0] self.verbose = self.wxobj.verbose from wx.lib.buttons import GenBitmapTextButton bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, (16, 16)) wx.Dialog.__init__(self, None, title="Dataset Dialog") self.ID_DONE = wx.NewId() self.SetSize((900, 800)) self.SetTitle("Please select files for the second condition.") mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(mainSizer) warningText = """ The Genetic Interactions method requires a total of four sets of datasets. Typically these are 2 strain backgrounds (e.g. Wildtype and Knockout) each grown under two conditions (e.g. in vitro and in vivo, or rich-media and presence of antibiotic). The Control and Experimental datasets added in the main TRANSIT interface are assumed to be the two strain backgrounds grown under the first condition. This interface allows you to add the remaining datasets for the second condition. """ warningStaticBox = wx.StaticText(self, wx.ID_ANY, warningText, (-1,-1), (-1, -1), wx.EXPAND) warningStaticBox.Wrap(800) mainSizer.Add(warningStaticBox, flag=wx.CENTER, border=5) # CONTROL ctrlSizerB = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Control Samples - Condition B" ), wx.VERTICAL ) bSizer2 = wx.BoxSizer( wx.HORIZONTAL ) self.ctrlRemoveButton = wx.Button( self, wx.ID_ANY, u"Remove", wx.DefaultPosition, (96,-1), 0 ) bSizer2.Add( self.ctrlRemoveButton, 0, wx.ALL, 5 ) self.ctrlView = wx.Button( self, wx.ID_ANY, u"Track View", wx.DefaultPosition, wx.DefaultSize, 0 ) self.ctrlView.Hide() bSizer2.Add( self.ctrlView, 0, wx.ALL, 5 ) self.ctrlScatter = wx.Button( self, wx.ID_ANY, u"Scatter", wx.DefaultPosition, wx.DefaultSize, 0 ) self.ctrlScatter.Hide() bSizer2.Add( self.ctrlScatter, 0, wx.ALL, 5 ) self.ctrlFilePicker = GenBitmapTextButton(self, 1, bmp, '[Click to add Control Dataset(s)]', size= wx.Size(500, -1)) bSizer2.Add( self.ctrlFilePicker, 1, wx.ALIGN_CENTER_VERTICAL, 5 ) ctrlSizerB.Add( bSizer2, 0, wx.EXPAND, 5 ) self.list_ctrl = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER ) self.list_ctrl.SetMaxSize(wx.Size(940,200)) ctrlSizerB.Add( self.list_ctrl, 1, wx.ALL|wx.EXPAND, 5 ) # EXPERIMENTAL expSizerB = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Experimental Samples - Condition B" ), wx.VERTICAL ) bSizer3 = wx.BoxSizer( wx.HORIZONTAL ) self.expRemoveButton = wx.Button( self, wx.ID_ANY, u"Remove", wx.DefaultPosition, (96,-1), 0 ) bSizer3.Add( self.expRemoveButton, 0, wx.ALL, 5 ) self.expView = wx.Button( self, wx.ID_ANY, u"Track View", wx.DefaultPosition, wx.DefaultSize, 0 ) self.expView.Hide() bSizer3.Add( self.expView, 0, wx.ALL, 5 ) self.expScatter = wx.Button( self, wx.ID_ANY, u"Scatter", wx.DefaultPosition, wx.DefaultSize, 0 ) self.expScatter.Hide() bSizer3.Add( self.expScatter, 0, wx.ALL, 5 ) self.expFilePicker = GenBitmapTextButton(self, 1, bmp, '[Click to add Experimental Dataset(s)]', size= wx.Size(500, -1)) bSizer3.Add( self.expFilePicker, 1, wx.ALIGN_CENTER_VERTICAL, 5 ) expSizerB.Add( bSizer3, 0, wx.EXPAND, 5 ) self.list_exp = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER ) self.list_exp.SetMaxSize(wx.Size(940, 200)) expSizerB.Add( self.list_exp, 1, wx.ALL|wx.EXPAND, 5 ) # MAIN mainSizer.Add( ctrlSizerB, 1, wx.EXPAND, 5 ) mainSizer.Add( expSizerB, 1, wx.EXPAND, 5 ) button_sizer = wx.BoxSizer(wx.HORIZONTAL) doneButton = wx.Button(self, self.ID_DONE, label='Done') cancelButton = wx.Button(self, wx.ID_CANCEL, label='Cancel') button_sizer.Add(doneButton, flag=wx.LEFT, border=5) button_sizer.Add(cancelButton, flag=wx.LEFT, border=5) self.expFilePicker.Bind( wx.EVT_BUTTON, self.loadExpFileFunc ) self.ctrlFilePicker.Bind( wx.EVT_BUTTON, self.loadCtrlFileFunc ) mainSizer.Add(button_sizer, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10) doneButton.Bind(wx.EVT_BUTTON, self.OnClose) cancelButton.Bind(wx.EVT_BUTTON, self.OnClose) self.ctrlFilePicker.Bind( wx.EVT_BUTTON, self.loadCtrlFileFunc ) self.expFilePicker.Bind( wx.EVT_BUTTON, self.loadExpFileFunc ) self.ctrlRemoveButton.Bind( wx.EVT_BUTTON, self.ctrlRemoveFunc ) self.expRemoveButton.Bind( wx.EVT_BUTTON, self.expRemoveFunc ) self.index_ctrl = 0 self.list_ctrl.InsertColumn(0, 'File', width=210) self.list_ctrl.InsertColumn(1, 'Total Reads', width=85) self.list_ctrl.InsertColumn(2, 'Density', width=85) self.list_ctrl.InsertColumn(3, 'Mean Count', width=90) self.list_ctrl.InsertColumn(4, 'Max Count', width=85) self.list_ctrl.InsertColumn(5, 'Full Path', width=403) self.index_exp = 0 self.list_exp.InsertColumn(0, 'File', width=210) self.list_exp.InsertColumn(1, 'Total Reads', width=85) self.list_exp.InsertColumn(2, 'Density', width=85) self.list_exp.InsertColumn(3, 'Mean Count', width=90) self.list_exp.InsertColumn(4, 'Max Count', width=85) self.list_exp.InsertColumn(5, 'Full Path',width=403) def OnClose(self, event): if self.IsModal(): self.EndModal(event.EventObject.Id) self.Close() else: self.Close() self.Destroy() def ctrlSelected(self, col=5): selected_ctrl = [] current = -1 while True: next = self.list_ctrl.GetNextSelected(current) if next == -1: break path = self.list_ctrl.GetItem(next, col).GetText() selected_ctrl.append(path) current = next return selected_ctrl # def loadCtrlFileFunc(self, event): try: dlg = wx.FileDialog( self, message="Choose a file", defaultDir=self.wxobj.workdir, defaultFile="", wildcard=u"Read Files (*.wig)|*.wig;|\nRead Files (*.txt)|*.txt;|\nRead Files (*.dat)|*.dat;|\nAll files (*.*)|*.*", style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() print "You chose the following Control file(s):" for fullpath in paths: print "\t%s" % fullpath self.loadCtrlFile(fullpath) dlg.Destroy() except Exception as e: transit_tools.transit_message("Error: %s" % e) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) # def expSelected(self, col=5): selected_exp = [] current = -1 while True: next = self.list_exp.GetNextSelected(current) if next == -1: break path = self.list_exp.GetItem(next, col).GetText() selected_exp.append(path) current = next return selected_exp def loadExpFileFunc(self, event): try: dlg = wx.FileDialog( self, message="Choose a file", defaultDir=self.wxobj.workdir, defaultFile="", wildcard=u"Read Files (*.wig)|*.wig;|\nRead Files (*.txt)|*.txt;|\nRead Files (*.dat)|*.dat;|\nAll files (*.*)|*.*", style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() print "You chose the following Experimental file(s):" for fullpath in paths: print "\t%s" % fullpath self.loadExpFile(fullpath) dlg.Destroy() except Exception as e: transit_tools.transit_message("Error: %s" % e) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) # def loadCtrlFile(self, fullpath): name = transit_tools.basename(fullpath) (density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_wig_stats(fullpath) self.list_ctrl.InsertItem(self.index_ctrl, name) self.list_ctrl.SetItem(self.index_ctrl, 1, "%1.1f" % (totalrd)) self.list_ctrl.SetItem(self.index_ctrl, 2, "%2.1f" % (density*100)) self.list_ctrl.SetItem(self.index_ctrl, 3, "%1.1f" % (meanrd)) self.list_ctrl.SetItem(self.index_ctrl, 4, "%d" % (maxrd)) self.list_ctrl.SetItem(self.index_ctrl, 5, "%s" % (fullpath)) self.list_ctrl.Select(self.index_ctrl) self.index_ctrl+=1 # def loadExpFile(self, fullpath): name = transit_tools.basename(fullpath) (density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_wig_stats(fullpath) self.list_exp.InsertItem(self.index_exp, name) self.list_exp.SetItem(self.index_exp, 1, "%1.1f" % (totalrd)) self.list_exp.SetItem(self.index_exp, 2, "%2.1f" % (density*100)) self.list_exp.SetItem(self.index_exp, 3, "%1.1f" % (meanrd)) self.list_exp.SetItem(self.index_exp, 4, "%d" % (maxrd)) self.list_exp.SetItem(self.index_exp, 5, "%s" % (fullpath)) self.list_exp.Select(self.index_exp) self.index_exp+=1 # def ctrlRemoveFunc(self, event): next = self.list_ctrl.GetNextSelected(-1) while next != -1: if self.verbose: transit_tools.transit_message("Removing control item (%d): %s" % (next, self.list_ctrl.GetItem(next, 0).GetText())) self.list_ctrl.DeleteItem(next) next = self.list_ctrl.GetNextSelected(-1) self.index_ctrl-=1 # def expRemoveFunc(self, event): next = self.list_exp.GetNextSelected(-1) while next != -1: if self.verbose: transit_tools.transit_message("Removing experimental item (%d): %s" % (next, self.list_exp.GetItem(next, 0).GetText())) self.list_exp.DeleteItem(next) next = self.list_exp.GetNextSelected(-1) self.index_exp-=1
def initUI(self): max_float = float("inf") min_float = float("-inf") # Create Validator Object self.validator_text = TextValidator() self.validator_number = NumberValidator() self.validator_browser = BrowserValidator() # -------------------------------------- # ---------- Create Sizers ---------- # -------------------------------------- # Box Sizer for Panel panelBox = wx.BoxSizer(wx.VERTICAL) # Grid Sizer for Parameters parameterSizer = wx.GridSizer(rows=13, cols=2, hgap=5, vgap=5) # Static Box for Parameters parameterBox = wx.StaticBox(self, wx.ID_ANY, u' Parámetros Iniciales: ') parameterBoxSizer = wx.StaticBoxSizer(parameterBox, wx.VERTICAL) # Button Sizer buttonSizer = wx.BoxSizer(wx.HORIZONTAL) # -------------------------------------- # --- Create Init Button and browser --- # -------------------------------------- # browser panel self.outputBrowser = BrowserPanel(self, u' Carpeta de Salida:', 'Carpeta de Salida') #set dir for images dir_image = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', 'images/')) # Create bitmap for Buttons bmpPlay = wx.BitmapFromImage( wx.Image(os.path.join(dir_image, 'play.png'))) # Init Button self.initButton = GenBitmapTextButton(self, wx.ID_ANY, bitmap=bmpPlay, label=u' Iniciar') # -------------------------------------------------------- # ---------- Create Labels and Inputs Fields ---------- # -------------------------------------------------------- # Nombre de la Muestra (string)-(- , -) label_sampleName = wx.StaticText(self, wx.ID_ANY, u' &Nombre de Muestra:') self.text_sampleName = wx.TextCtrl(self, wx.ID_ANY, style=wx.ALIGN_RIGHT, name="Nombre de Muestra") # Usuario (string)-(-,-) label_user = wx.StaticText(self, wx.ID_ANY, u' &Usuario:') self.text_user = wx.TextCtrl(self, wx.ID_ANY, style=wx.ALIGN_RIGHT, name="Usuario") # Equipo de la muestra (string)-(-,-) label_equipment = wx.StaticText(self, wx.ID_ANY, u' &Equipo de Muestreo:') self.text_equipment = wx.TextCtrl(self, wx.ID_ANY, style=wx.ALIGN_RIGHT, name="Equipo de Muestra") # Temperatura (Decimal)-(25.0, 80.0) label_temp = wx.StaticText(self, wx.ID_ANY, u' &Temperatura (°C):') self.text_temp = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="40", min=min_float, max=max_float, initial=40.0, inc=0.1, name="Temperatura") # Dilución (Decimal)-(0.0, 1.0) label_dilution = wx.StaticText(self, wx.ID_ANY, u' &Dilución:') self.text_dilution = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="0", min=min_float, max=max_float, initial=0, inc=0.05, name="Dilucion") # Fecha (Date)-() label_date = wx.StaticText(self, wx.ID_ANY, u' &Fecha:') self.text_date = wx.DatePickerCtrl(self, wx.ID_ANY, style=wx.DP_DROPDOWN | wx.ALIGN_RIGHT, name="Fecha") # Volumen para toma de Imagenes (Decimal)-(0.5, 1000) label_volume = wx.StaticText(self, wx.ID_ANY, u' &Volumen (ml):') self.text_volume = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="0.5", min=min_float, max=max_float, initial=0.5, inc=0.5, name="Volumen") # Concentracion de contaminante (Decimal)-(0.0, 1000.0) label_contaminantConcentration = wx.StaticText( self, wx.ID_ANY, u' &Concentración de contaminante:') self.text_contaminantConcentration = wx.SpinCtrlDouble( self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="0.5", min=min_float, max=max_float, initial=0.5, inc=0.5, name="Contaminante") # Concentracion de cougalante estimado (Decimal)-(0.0, 1000.0) label_coagulantConcentration = wx.StaticText( self, wx.ID_ANY, u' &Concentración de coagulante:') self.text_coagulantConcentration = wx.SpinCtrlDouble( self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="0.5", min=min_float, max=max_float, initial=0.5, inc=0.5, name="Coagulante") # Objetivo X (Entero)-(10, 100) label_objectiveX = wx.StaticText(self, wx.ID_ANY, u' &Objetivo X:') self.text_objectiveX = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="10", min=min_float, max=max_float, initial=10, inc=1, name="ObjetivoX") # Area del Visual (Decimal)-(- , -) label_visualArea = wx.StaticText(self, wx.ID_ANY, u' &Visual del área:') self.text_visualArea = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="0", min=min_float, max=max_float, initial=0, inc=1, name="Visual") # Voltaje (Decimal)-(1.0, 10.0) label_volt = wx.StaticText(self, wx.ID_ANY, u' &Voltaje (V):') self.text_volt = wx.SpinCtrlDouble(self, wx.ID_ANY, style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT, value="1", min=min_float, max=max_float, initial=1, inc=0.1, name="Voltaje") # Observaciones (String)-() label_observations = wx.StaticText(self, wx.ID_ANY, u' &Observaciones:') self.text_observations = wx.TextCtrl( self, wx.ID_ANY, size=(200, 300), style=wx.TE_MULTILINE | wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER, name="Objetivos") # -------------------------------------------------------- # ---------- Add Labels and Inputs to Sizer ------------- # -------------------------------------------------------- parameterSizer.Add(label_sampleName, 1, wx.EXPAND) parameterSizer.Add(self.text_sampleName, 1, wx.EXPAND) parameterSizer.Add(label_user, 1, wx.EXPAND) parameterSizer.Add(self.text_user, 1, wx.EXPAND) parameterSizer.Add(label_equipment, 1, wx.EXPAND) parameterSizer.Add(self.text_equipment, 1, wx.EXPAND) parameterSizer.Add(label_temp, 1, wx.EXPAND) parameterSizer.Add(self.text_temp, 1, wx.EXPAND) parameterSizer.Add(label_dilution, 1, wx.EXPAND) parameterSizer.Add(self.text_dilution, 1, wx.EXPAND) parameterSizer.Add(label_date, 1, wx.EXPAND) parameterSizer.Add(self.text_date, 1, wx.EXPAND) parameterSizer.Add(label_volume, 1, wx.EXPAND) parameterSizer.Add(self.text_volume, 1, wx.EXPAND) parameterSizer.Add(label_contaminantConcentration, 1, wx.EXPAND) parameterSizer.Add(self.text_contaminantConcentration, 1, wx.EXPAND) parameterSizer.Add(label_coagulantConcentration, 1, wx.EXPAND) parameterSizer.Add(self.text_coagulantConcentration, 1, wx.EXPAND) parameterSizer.Add(label_objectiveX, 1, wx.EXPAND) parameterSizer.Add(self.text_objectiveX, 1, wx.EXPAND) parameterSizer.Add(label_visualArea, 1, wx.EXPAND) parameterSizer.Add(self.text_visualArea, 1, wx.EXPAND) parameterSizer.Add(label_volt, 1, wx.EXPAND) parameterSizer.Add(self.text_volt, 1, wx.EXPAND) parameterSizer.Add(label_observations, 1, wx.EXPAND) parameterSizer.Add(self.text_observations, 0, wx.EXPAND) # -------------------------------------------------------- # -------------------- Add Sizers ----------------------- # -------------------------------------------------------- # Add Parameters Sizer to parameter Box parameterBoxSizer.AddSpacer(10) parameterBoxSizer.Add(parameterSizer, 1, wx.EXPAND, 20) # Add buttons to Sizer buttonSizer.Add(self.initButton, 1, wx.ALIGN_CENTER) buttonSizer.AddSpacer(10) # Add browser and Parameters Sizer to Panel Sizer panelBox.Add(self.outputBrowser, 1, wx.EXPAND) panelBox.AddSpacer(15) panelBox.Add(wx.StaticLine(self), 1, wx.EXPAND) panelBox.AddSpacer(15) panelBox.Add(parameterBoxSizer, 1, wx.EXPAND, 20) panelBox.AddSpacer(10) panelBox.Add(wx.StaticLine(self), 1, wx.EXPAND) panelBox.AddSpacer(10) panelBox.AddSizer(buttonSizer, 0, wx.ALIGN_CENTER, 20) panelBox.AddSpacer(10) # Add panelSizer to Panel self.SetSizerAndFit(panelBox)