def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False ID = self.Selection()[0].IDcategorie # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Ajouter item = wx.MenuItem(menuPop, 10, _(u"Ajouter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ajouter.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Ajouter, id=10) menuPop.AppendSeparator() # Item Modifier item = wx.MenuItem(menuPop, 20, _(u"Modifier")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) if noSelection == True : item.Enable(False) # Item Supprimer item = wx.MenuItem(menuPop, 30, _(u"Supprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Supprimer.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Supprimer, id=30) if noSelection == True : item.Enable(False) menuPop.AppendSeparator() # Item Deplacer vers le haut item = wx.MenuItem(menuPop, 40, _(u"Déplacer vers le haut")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_haut.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Monter, id=40) if noSelection == True : item.Enable(False) # Item Déplacer vers le bas item = wx.MenuItem(menuPop, 50, _(u"Déplacer vers le bas")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_bas.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Descendre, id=50) if noSelection == True : item.Enable(False) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=60) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=70) self.PopupMenu(menuPop) menuPop.Destroy()
def __init__(self, parent, master): """Opbouwen van het scherm parent is een SingleDataInterface, master is een HotKeyPanel """ shared.MergeMixin.__init__(self, master) wx.Dialog.__init__(self, parent, title="TCCM", size=(1000, 600), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) # image voor het vinkje opzetten dat m.b.v. SetItemColumnImage ingesteld kan worden self.imglist = wx.ImageList(16, 16) # self.todoimage = self.imglist.Add(wx.NullBitmap) self.okimage = self.imglist.Add( wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK)) self.todoimage = self.imglist.Add( wx.ArtProvider.GetBitmap(wx.ART_DEL_BOOKMARK)) self.listkeys = MyListCtrl(self, style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.listkeys.InsertColumn(0, 'Key') self.listkeys.InsertColumn(1, 'Description') self.listkeys.SetImageList(self.imglist, wx.IMAGE_LIST_SMALL) # self.listkeys.SetToolTip(self.popuptext) -- nog iets op vinden self.listkeys.Bind(wx.EVT_LIST_ITEM_SELECTED, self.select_match_fromkeys) self.findkeybutton = self.create_findbutton(columns=('key', 'text')) self.findkeybutton.SetSelection(1) self.findkeytext = wx.TextCtrl(self, size=(120, -1)) self.nextkey = wx.Button(self, label='&Next', size=(50, -1)) self.nextkey.Bind(wx.EVT_BUTTON, self.findnextkey) self.prevkey = wx.Button(self, label='&Prev', size=(50, -1)) self.prevkey.Bind(wx.EVT_BUTTON, self.findprevkey) self.listcmds = MyListCtrl(self, style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.listcmds.InsertColumn(0, 'Command') self.listcmds.InsertColumn(1, 'Description') # self.listcmds.SetToolTip(self.popuptext) -- nog iets op vinden self.listcmds.Bind(wx.EVT_LIST_ITEM_SELECTED, self.select_match_from_cmds) self.findcmdbutton = self.create_findbutton(columns=('cmd', 'text')) self.findcmdbutton.SetSelection(1) self.findcmdtext = wx.TextCtrl(self, size=(120, -1)) self.nextcmd = wx.Button(self, label='Ne&xt', size=(50, -1)) self.nextcmd.Bind(wx.EVT_BUTTON, self.findnextcmd) self.prevcmd = wx.Button(self, label='Pre&v', size=(50, -1)) self.prevcmd.Bind(wx.EVT_BUTTON, self.findprevcmd) self.listmatches = MyListCtrl(self, style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.listmatches.InsertColumn(0, 'Key') self.listmatches.InsertColumn(1, 'Command') self.listmatches.Bind(wx.EVT_LIST_ITEM_SELECTED, self.select_listitems_from_matches) self.btn_match = wx.Button(self, label="&+ Add/Replace match") self.btn_match.Bind(wx.EVT_BUTTON, self.make_match) self.btn_delete = wx.Button(self, label="&- Discard match") self.btn_delete.Bind(wx.EVT_BUTTON, self.delete_match) self.btn_load = wx.Button(self, label="&Load matches") self.btn_load.Bind(wx.EVT_BUTTON, self.load_matches) self.btn_clear = wx.Button(self, label="&Clear All") self.btn_clear.Bind(wx.EVT_BUTTON, self.reset_all) self.btn_save = wx.Button(self, label="&Save matches") self.btn_save.Bind(wx.EVT_BUTTON, self.save_matches) self.btn_quit = wx.Button(self, label="&Afsluiten") self.btn_quit.Bind(wx.EVT_BUTTON, self.close) self.btn_build = wx.Button(self, label="&Build CSV") self.btn_build.Bind(wx.EVT_BUTTON, self.confirm) vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) vbox2 = wx.BoxSizer(wx.VERTICAL) vbox2.Add(self.listkeys, 1, wx.EXPAND) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox2.AddStretchSpacer() hbox2.Add(self.findkeybutton, 0, wx.ALIGN_CENTER_VERTICAL) hbox2.Add(self.findkeytext, 0, wx.ALIGN_CENTER_VERTICAL) hbox2.Add(self.nextkey, 0) hbox2.Add(self.prevkey, 0) hbox2.AddStretchSpacer() vbox2.Add(hbox2, 0, wx.EXPAND) hbox.Add(vbox2, 1, wx.EXPAND | wx.LEFT, 10) vbox2 = wx.BoxSizer(wx.VERTICAL) vbox2.Add(self.listcmds, 1, wx.EXPAND) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox2.AddStretchSpacer() hbox2.Add(self.findcmdbutton, 0, wx.ALIGN_CENTER_VERTICAL) hbox2.Add(self.findcmdtext, 0, wx.ALIGN_CENTER_VERTICAL) hbox2.Add(self.nextcmd, 0) hbox2.Add(self.prevcmd, 0) hbox2.AddStretchSpacer() vbox2.Add(hbox2, 0, wx.EXPAND) hbox.Add(vbox2, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5) vbox2 = wx.BoxSizer(wx.VERTICAL) vbox2.Add(self.listmatches, 1, wx.EXPAND) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox2.AddStretchSpacer() hbox2.Add(self.btn_match) hbox2.Add(self.btn_delete) hbox2.AddStretchSpacer() vbox2.Add(hbox2, 0, wx.EXPAND) hbox.Add(vbox2, 1, wx.EXPAND | wx.RIGHT, 10) vbox.Add(hbox, 1, wx.EXPAND) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.AddStretchSpacer() hbox.Add(self.btn_load, 0, wx.ALL, 2) hbox.Add(self.btn_clear, 0, wx.ALL, 2) hbox.Add(self.btn_save, 0, wx.ALL, 2) hbox.Add(self.btn_quit, 0, wx.ALL, 2) hbox.Add(self.btn_build) hbox.AddStretchSpacer() vbox.Add(hbox, 0, wx.ALIGN_CENTER_HORIZONTAL) self.SetAutoLayout(True) self.SetSizer(vbox) # vbox.SetSizeHints(self) # dit dus juist niet; sizer bepaalt grootte van venster accel_list = [] for text, callback, keyseq, desc in self.getshortcuts(): menuitem = wx.MenuItem(None, -1, text) self.Bind(wx.EVT_MENU, callback, menuitem) accel = wx.AcceleratorEntry(cmd=menuitem.GetId()) ok = accel.FromString(keyseq) if ok: accel_list.append(accel) accel_table = wx.AcceleratorTable(accel_list) self.SetAcceleratorTable(accel_table) self.load_files()
def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False ID = self.Selection()[0].IDdepot_cotisation # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Modifier item = wx.MenuItem(menuPop, 10, _(u"Ajouter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ajouter.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Ajouter, id=10) menuPop.AppendSeparator() # Item Ajouter item = wx.MenuItem(menuPop, 20, _(u"Modifier")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) if noSelection == True: item.Enable(False) # Item Supprimer item = wx.MenuItem(menuPop, 30, _(u"Supprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Supprimer.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Supprimer, id=30) if noSelection == True: item.Enable(False) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=40) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=50) menuPop.AppendSeparator() # Item Export Texte item = wx.MenuItem(menuPop, 600, _(u"Exporter au format Texte")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Texte2.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportTexte, id=600) # Item Export Excel item = wx.MenuItem(menuPop, 700, _(u"Exporter au format Excel")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Excel.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportExcel, id=700) self.PopupMenu(menuPop) menuPop.Destroy()
def getMenu(cls, mainItem, selection, *fullContexts): """ getMenu returns a menu that is used with wx.PopupMenu. mainItem: usually, provides item which was clicked. Useful for single- item actions when user has multiple items selected selection: provides a list of what was selected. If only 1 item was selected, it's is a 1-item list or tuple. Can also be None for contexts without selection, such as statsPane or projected view fullContexts: a number of tuples of the following tuple: srcContext - context were menu was spawned, eg: projectedFit, cargoItem, etc itemContext - usually the name of the item's category eg: (('fittingModule', 'Module'), ('fittingShip', 'Ship')) (('marketItemGroup', 'Implant'),) (('fittingShip', 'Ship'),) """ ContextMenu._idxid = -1 debug_start = len(ContextMenu._ids) rootMenu = wx.Menu() rootMenu.info = {} rootMenu.selection = (selection,) if not hasattr(selection, "__iter__") else selection rootMenu.mainItem = mainItem empty = True for i, fullContext in enumerate(fullContexts): display_amount = 0 srcContext = fullContext[0] try: itemContext = fullContext[1] except IndexError: itemContext = None for menuHandler in cls.menus: # loop through registered menus m = menuHandler() if m._baseDisplay(srcContext, mainItem, selection): display_amount += 1 texts = m._baseGetText(itemContext, mainItem, selection) if isinstance(texts, str): texts = (texts,) bitmap = m._baseGetBitmap(srcContext, mainItem, selection) multiple = not isinstance(bitmap, wx.Bitmap) for it, text in enumerate(texts): id = ContextMenu.nextID() check = m.checked rootItem = wx.MenuItem(rootMenu, id, text, kind=wx.ITEM_NORMAL if m.checked is None else wx.ITEM_CHECK) rootMenu.info[id] = (m, fullContext, it) sub = m._baseGetSubMenu(srcContext, mainItem, selection, rootMenu, it, rootItem) if sub is None: # if there is no sub menu, bind the handler to the rootItem rootMenu.Bind(wx.EVT_MENU, ContextMenu.handler, rootItem) elif sub: # If sub exists and is not False, set submenu. # Sub might return False when we have a mix of # single menu items and submenus (see: damage profile # context menu) # # If there is a submenu, it is expected that the sub # logic take care of it's own bindings, including for # any single root items. No binding is done here # # It is important to remember that when binding sub # menu items, the menu to bind to depends on platform. # Windows should bind to rootMenu, and all other # platforms should bind to sub menu. See existing # implementations for examples. rootItem.SetSubMenu(sub) if bitmap is not None: if multiple: bp = bitmap[it] if bp: rootItem.SetBitmap(bp) else: rootItem.SetBitmap(bitmap) rootMenu.Append(rootItem) if check is not None: rootItem.Check(check) rootItem.Enable(m.enabled) empty = False if display_amount > 0 and i != len(fullContexts) - 1: rootMenu.AppendSeparator() debug_end = len(ContextMenu._ids) if debug_end - debug_start: pyfalog.debug("{} new IDs created for this menu".format(debug_end - debug_start)) return rootMenu if empty is False else None
def CreateRightClickMenu(self): self._rmenu = wx.Menu() item = wx.MenuItem(self._rmenu, MENU_EDIT_DELETE_PAGE, "Close Tab\tCtrl+F4", "Close Tab") self._rmenu.Append(item)
def create_menu_item(menu, label, func): item = wx.MenuItem(menu, -1, label) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) menu.AppendItem(item) return item
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=App_title, pos=wx.DefaultPosition, size=wx.Size(913, 641), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTION)) bSizer1 = wx.BoxSizer(wx.HORIZONTAL) bSizer2 = wx.BoxSizer(wx.HORIZONTAL) bSizer3 = wx.BoxSizer(wx.VERTICAL) sbSizer1 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"原始图像"), wx.VERTICAL) self.orgin_img = wx.StaticBitmap(sbSizer1.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, 0) sbSizer1.Add(self.orgin_img, 1, wx.ALL | wx.EXPAND, 5) bSizer3.Add(sbSizer1, 1, wx.EXPAND, 5) sbSizer2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"人姿和手部检测"), wx.VERTICAL) self.result_img = wx.StaticBitmap(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, 0) sbSizer2.Add(self.result_img, 1, wx.ALL | wx.EXPAND, 5) bSizer3.Add(sbSizer2, 1, wx.EXPAND, 5) bSizer2.Add(bSizer3, 1, wx.EXPAND, 5) bSizer4 = wx.BoxSizer(wx.VERTICAL) sbSizer3 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"运行日志"), wx.VERTICAL) self.tips = wx.TextCtrl(sbSizer3.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY) sbSizer3.Add(self.tips, 1, wx.ALL | wx.EXPAND, 5) bSizer4.Add(sbSizer3, 1, wx.EXPAND, 5) sbSizer4 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"检测结果"), wx.VERTICAL) self.result = wx.TextCtrl(sbSizer4.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY) sbSizer4.Add(self.result, 1, wx.ALL | wx.EXPAND, 5) bSizer4.Add(sbSizer4, 1, wx.EXPAND, 5) bSizer2.Add(bSizer4, 1, wx.EXPAND, 5) bSizer5 = wx.BoxSizer(wx.VERTICAL) sbSizer5 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"控制台"), wx.VERTICAL) sbSizer6 = wx.StaticBoxSizer( wx.StaticBox(sbSizer5.GetStaticBox(), wx.ID_ANY, u"选择视频或文件"), wx.HORIZONTAL) self.m_button7 = wx.Button(sbSizer6.GetStaticBox(), wx.ID_ANY, u"选择图片", wx.DefaultPosition, wx.DefaultSize, 0) sbSizer6.Add(self.m_button7, 1, wx.ALL | wx.EXPAND, 5) self.m_button8 = wx.Button(sbSizer6.GetStaticBox(), wx.ID_ANY, u"选择视频", wx.DefaultPosition, wx.DefaultSize, 0) sbSizer6.Add(self.m_button8, 1, wx.ALL | wx.EXPAND, 5) sbSizer5.Add(sbSizer6, 0, wx.EXPAND, 5) sbSizer7 = wx.StaticBoxSizer( wx.StaticBox(sbSizer5.GetStaticBox(), wx.ID_ANY, u"特征提取"), wx.VERTICAL) self.m_button1 = wx.Button(sbSizer7.GetStaticBox(), wx.ID_ANY, u"特征提取", wx.DefaultPosition, wx.DefaultSize, 0) sbSizer7.Add(self.m_button1, 0, wx.ALL | wx.EXPAND, 5) sbSizer5.Add(sbSizer7, 0, wx.EXPAND, 5) sbSizer8 = wx.StaticBoxSizer( wx.StaticBox(sbSizer5.GetStaticBox(), wx.ID_ANY, u"手语预测"), wx.VERTICAL) self.m_button5 = wx.Button(sbSizer8.GetStaticBox(), wx.ID_ANY, u"选择分类模型", wx.DefaultPosition, wx.DefaultSize, 0) sbSizer8.Add(self.m_button5, 0, wx.ALL | wx.EXPAND, 5) self.m_button6 = wx.Button(sbSizer8.GetStaticBox(), wx.ID_ANY, u"预测", wx.DefaultPosition, wx.DefaultSize, 0) sbSizer8.Add(self.m_button6, 0, wx.ALL | wx.EXPAND, 5) sbSizer5.Add(sbSizer8, 0, wx.EXPAND, 5) sbSizer9 = wx.StaticBoxSizer( wx.StaticBox(sbSizer5.GetStaticBox(), wx.ID_ANY, u"示例图"), wx.VERTICAL) self.black_img = wx.StaticBitmap(sbSizer9.GetStaticBox(), wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, 0) sbSizer9.Add(self.black_img, 1, wx.ALL | wx.EXPAND, 5) sbSizer5.Add(sbSizer9, 1, wx.EXPAND, 5) bSizer5.Add(sbSizer5, 1, wx.EXPAND, 5) bSizer2.Add(bSizer5, 1, wx.EXPAND, 5) bSizer1.Add(bSizer2, 1, wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() self.m_menubar1 = wx.MenuBar(0) self.m_menubar1.SetForegroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) self.m_menubar1.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) self.m_menu1 = wx.Menu() self.m_menuItem1 = wx.MenuItem(self.m_menu1, wx.ID_ANY, u"图片", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu1.Append(self.m_menuItem1) self.m_menuItem2 = wx.MenuItem(self.m_menu1, wx.ID_ANY, u"视频", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu1.Append(self.m_menuItem2) self.m_menubar1.Append(self.m_menu1, u"检测") self.m_menu2 = wx.Menu() self.m_menubar1.Append(self.m_menu2, u"采集") self.m_menu3 = wx.Menu() self.m_menubar1.Append(self.m_menu3, u"关于") self.SetMenuBar(self.m_menubar1) self.m_statusBar2 = self.CreateStatusBar(1, wx.STB_SIZEGRIP, wx.ID_ANY) self.m_statusBar2.SetForegroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) self.m_statusBar2.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)) self.Centre(wx.BOTH) # Connect Events self.m_button7.Bind(wx.EVT_BUTTON, self.img_btn) self.m_button8.Bind(wx.EVT_BUTTON, self.video_btn) self.m_button1.Bind(wx.EVT_BUTTON, self.feature_btn) self.m_button5.Bind(wx.EVT_BUTTON, self.chosemodel_btn) self.m_button6.Bind(wx.EVT_BUTTON, self.predict_btn) """界面""" self.image_demo = wx.Image(DEMO, wx.BITMAP_TYPE_ANY).Scale(500, 400) self.bmp = wx.StaticBitmap(self.black_img, -1, wx.Bitmap(self.image_demo)) # 设置窗口标题的图标 self.icon = wx.Icon(ICO, wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) print("wxpython界面初始化加载完成!") """参数""" # self.VIDEO_STREAM = False self.IMAGE_STREAM = False self.orgin_img_show = root_path + 'docs/images/brave_40.jpg' # 默认预测图片 self.model_path = root_path + 'model/' # 训练的深度模型 self._loadmodel() # 加载OpenPose和yolo模型 self.beyes_model = root_path + 'model/train_model.m' # 默认贝叶斯模型 self.XX_test = [] # 测试集
def initMenu(self): menuBar = wx.MenuBar() #生成菜单栏 menu_Font = wx.Font() #Font(faceName="consolas",pointsize=20) menu_Font.SetPointSize(14) menu_Font.SetWeight(wx.BOLD) registerMenu = wx.Menu() #生成菜单 self.new_register = wx.MenuItem(registerMenu, ID_NEW_REGISTER, "新建录入") self.new_register.SetBitmap(wx.Bitmap("drawable/new_register.png")) self.new_register.SetTextColour("SLATE BLUE") self.new_register.SetFont(menu_Font) registerMenu.Append(self.new_register) self.finish_register = wx.MenuItem(registerMenu, ID_FINISH_REGISTER, "完成录入") self.finish_register.SetBitmap( wx.Bitmap("drawable/finish_register.png")) self.finish_register.SetTextColour("SLATE BLUE") self.finish_register.SetFont(menu_Font) self.finish_register.Enable(False) registerMenu.Append(self.finish_register) puncardMenu = wx.Menu() self.start_punchcard = wx.MenuItem(puncardMenu, ID_START_PUNCHCARD, "开始签到") self.start_punchcard.SetBitmap( wx.Bitmap("drawable/start_punchcard.png")) self.start_punchcard.SetTextColour("SLATE BLUE") self.start_punchcard.SetFont(menu_Font) puncardMenu.Append(self.start_punchcard) self.end_puncard = wx.MenuItem(puncardMenu, ID_END_PUNCARD, "结束签到") self.end_puncard.SetBitmap(wx.Bitmap("drawable/end_puncard.png")) self.end_puncard.SetTextColour("SLATE BLUE") self.end_puncard.SetFont(menu_Font) self.end_puncard.Enable(False) puncardMenu.Append(self.end_puncard) logcatMenu = wx.Menu() self.open_logcat = wx.MenuItem(logcatMenu, ID_OPEN_LOGCAT, "打开日志") self.open_logcat.SetBitmap(wx.Bitmap("drawable/open_logcat.png")) self.open_logcat.SetFont(menu_Font) self.open_logcat.SetTextColour("SLATE BLUE") logcatMenu.Append(self.open_logcat) self.close_logcat = wx.MenuItem(logcatMenu, ID_CLOSE_LOGCAT, "关闭日志") self.close_logcat.SetBitmap(wx.Bitmap("drawable/close_logcat.png")) self.close_logcat.SetFont(menu_Font) self.close_logcat.SetTextColour("SLATE BLUE") logcatMenu.Append(self.close_logcat) menuBar.Append(registerMenu, "&人脸录入") menuBar.Append(puncardMenu, "&刷脸签到") menuBar.Append(logcatMenu, "&考勤日志") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnNewRegisterClicked, id=ID_NEW_REGISTER) self.Bind(wx.EVT_MENU, self.OnFinishRegisterClicked, id=ID_FINISH_REGISTER) self.Bind(wx.EVT_MENU, self.OnStartPunchCardClicked, id=ID_START_PUNCHCARD) self.Bind(wx.EVT_MENU, self.OnEndPunchCardClicked, id=ID_END_PUNCARD) self.Bind(wx.EVT_MENU, self.OnOpenLogcatClicked, id=ID_OPEN_LOGCAT) self.Bind(wx.EVT_MENU, self.OnCloseLogcatClicked, id=ID_CLOSE_LOGCAT)
def OnContextMenu(self, event): """Ouverture du menu contextuel """ menuPop = UTILS_Adaptations.Menu() item = wx.MenuItem(menuPop, ID_AUJOURDHUI, _(u"Aujourd'hui")) item.SetBitmap( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Date_actuelle.png"), wx.BITMAP_TYPE_PNG)) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=ID_AUJOURDHUI) item = wx.MenuItem(menuPop, ID_HIER, _(u"Hier")) item.SetBitmap( wx.Bitmap( Chemins.GetStaticPath("Images/16x16/Date_precedente.png"), wx.BITMAP_TYPE_PNG)) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=ID_HIER) item = wx.MenuItem(menuPop, ID_DEMAIN, _(u"Demain")) item.SetBitmap( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Date_suivante.png"), wx.BITMAP_TYPE_PNG)) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=ID_DEMAIN) menuPop.AppendSeparator() listeFonctions = [ (ID_SEMAINE_ACTUELLE, _(u"Semaine actuelle")), (ID_SEMAINE_PRECEDENTE, _(u"Semaine précédente")), (ID_SEMAINE_SUIVANTE, _(u"Semaine suivante")), (None, None), (ID_MOIS_ACTUEL, _(u"Mois actuel")), (ID_MOIS_PRECEDENT, _(u"Mois précédent")), (ID_MOIS_SUIVANT, _(u"Mois suivant")), (None, None), (ID_ANNEE_ACTUELLE, _(u"Année actuelle")), (ID_ANNEE_PRECEDENTE, _(u"Année précédente")), (ID_ANNEE_SUIVANTE, _(u"Année suivante")), ] for id, label in listeFonctions: if id == None: menuPop.AppendSeparator() else: sousMenu = UTILS_Adaptations.Menu() sousMenu.AppendItem( wx.MenuItem(menuPop, id + 1, _(u"Date de début"))) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=id + 1) sousMenu.AppendItem( wx.MenuItem(menuPop, id + 2, _(u"Date de fin"))) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=id + 2) item = menuPop.AppendMenu(id, label, sousMenu) menuPop.AppendSeparator() item = wx.MenuItem(menuPop, ID_AIDE, _(u"Aide")) item.SetBitmap( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Aide.png"), wx.BITMAP_TYPE_PNG)) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnActionMenu, id=ID_AIDE) self.PopupMenu(menuPop) menuPop.Destroy()
def AddItem(self, label, callback): item = wx.MenuItem(self, wx.NewId(), label) self.AppendItem(item) self.Bind(wx.EVT_MENU, callback, item) return item
def __init__(self): """ Constructor. """ wx.Frame.__init__ ( self, None, id = wx.ID_ANY, title = u"Bernardo Plaza Project", pos = (0,0), size = wx.Size( 320,240 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.Size( 320,240 ), wx.Size( 320,240 ) ) self.SetFont( wx.Font( 8, 74, 90, 90, False, "Calibri" ) ) self.statusbar = self.CreateStatusBar( 2, wx.ST_SIZEGRIP, wx.ID_ANY ) self.statusbar.SetStatusWidths([-1, 80]) self.statusbar.SetFont( wx.Font( 6, 74, 90, 91, False, "Calibri Light" ) ) statusbar_fields = ['Ready','Time'] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.timer = wx.Timer(self) self.timer.Start(1000) self.timerDTC = wx.Timer(self, id=2) self.menubar = wx.MenuBar( 0 ) self.menuFile = wx.Menu() self.menuSettings = wx.Menu() self.menuSensors = wx.MenuItem( self.menuSettings, wx.ID_ANY, u"Sensors", wx.EmptyString, wx.ITEM_NORMAL ) self.menuSensors.SetBitmap( wx.Bitmap( u"./icons/Industry-Electrical-Sensor-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuSettings.AppendItem( self.menuSensors ) self.menuRecordsSettings = wx.MenuItem( self.menuSettings, wx.ID_ANY, u"Records", wx.EmptyString, wx.ITEM_NORMAL ) self.menuRecordsSettings.SetBitmap( wx.Bitmap( u"./icons/Actions-office-chart-line-stacked-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuSettings.AppendItem( self.menuRecordsSettings ) self.menuAlarm = wx.MenuItem( self.menuSettings, wx.ID_ANY, u"Alarms", wx.EmptyString, wx.ITEM_NORMAL ) self.menuAlarm.SetBitmap( wx.Bitmap( u"./icons/megaphone-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuSettings.AppendItem( self.menuAlarm ) self.menuSerial = wx.MenuItem( self.menuSettings, wx.ID_ANY, u"Serial port", wx.EmptyString, wx.ITEM_NORMAL ) self.menuSerial.SetBitmap( wx.Bitmap( u"./icons/port-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuSettings.AppendItem( self.menuSerial ) self.menuEcoMode = wx.MenuItem( self.menuSettings, wx.ID_ANY, u"Enable Eco Mode", wx.EmptyString, wx.ITEM_CHECK ) self.menuEcoMode.SetBitmap( wx.Bitmap( u"./icons/Heart-green-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuSettings.AppendItem( self.menuEcoMode ) self.menuFile.AppendSubMenu( self.menuSettings, u"Settings" ) self.menuRecords = wx.MenuItem( self.menuFile, wx.ID_ANY, u"Records", wx.EmptyString, wx.ITEM_NORMAL ) self.menuRecords.SetBitmap( wx.Bitmap( u"./icons/Folder-Chart-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuFile.AppendItem( self.menuRecords ) self.menuDTC = wx.MenuItem( self.menuFile, wx.ID_ANY, u"Diganostic Trouble Code", wx.EmptyString, wx.ITEM_NORMAL ) self.menuDTC.SetBitmap( wx.Bitmap( u"./icons/Transport-Engine-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuFile.AppendItem( self.menuDTC ) self.menuFile.AppendSeparator() self.menuModes = wx.Menu() self.menuGraphical = wx.MenuItem( self.menuModes, wx.ID_ANY, u"Graphical", wx.EmptyString, wx.ITEM_NORMAL ) self.menuGraphical.SetBitmap( wx.Bitmap( u"./icons/speedometer-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuModes.AppendItem( self.menuGraphical ) self.menuNumerical = wx.MenuItem( self.menuModes, wx.ID_ANY, u"Numerical", wx.EmptyString, wx.ITEM_NORMAL ) self.menuNumerical.SetBitmap( wx.Bitmap( u"./icons/Industry-Display-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuModes.AppendItem( self.menuNumerical ) self.menuSensorList = wx.MenuItem( self.menuModes, wx.ID_ANY, u"Sensor List", wx.EmptyString, wx.ITEM_NORMAL ) self.menuSensorList.SetBitmap( wx.Bitmap( u"./icons/Data-List-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuModes.AppendItem( self.menuSensorList ) self.menuFile.AppendSubMenu( self.menuModes, u"Modes" ) self.menuQuit = wx.MenuItem( self.menuFile, wx.ID_ANY, u"Quit", wx.EmptyString, wx.ITEM_NORMAL ) self.menuQuit.SetBitmap( wx.Bitmap( u"./icons/Actions-dialog-cancel-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuFile.AppendItem( self.menuQuit ) self.menubar.Append( self.menuFile, u"File" ) menuView = wx.Menu() self.menuStatus = wx.MenuItem( menuView, wx.ID_ANY, u"Show Status Bar", wx.EmptyString, wx.ITEM_CHECK ) self.shst = menuView.AppendItem( self.menuStatus ) menuView.Check(self.shst.GetId(), True) self.menubar.Append( menuView, u"View" ) self.menuHelp = wx.Menu() self.menuAbout = wx.MenuItem( self.menuHelp, wx.ID_ANY, u"About", wx.EmptyString, wx.ITEM_NORMAL ) self.menuAbout.SetBitmap( wx.Bitmap( u"./icons/Actions-help-about-icon.png", wx.BITMAP_TYPE_ANY ) ) self.menuHelp.AppendItem( self.menuAbout ) self.menubar.Append( self.menuHelp, u"Help" ) self.SetMenuBar( self.menubar ) self.panelLoading = OBDLoadingPanel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.panelLoading, 1, wx.EXPAND) self.SetSizer(self.sizer) self.panelLoading.showLoadingScreen() self.panelLoading.SetFocus() #OBDLoadingPanel.gif.Play(False) # Connect Events self.Bind( wx.EVT_MENU, self.OnSensors, id = self.menuSensors.GetId() ) self.Bind( wx.EVT_MENU, self.OnRecords, id = self.menuRecords.GetId() ) self.Bind( wx.EVT_MENU, self.OnAlarms, id = self.menuAlarm.GetId() ) self.Bind( wx.EVT_MENU, self.OnEcoMode, id = self.menuEcoMode.GetId() ) self.Bind( wx.EVT_MENU, self.OnRecordsSettings, id = self.menuRecordsSettings.GetId() ) self.Bind( wx.EVT_MENU, self.OnDTC, id = self.menuDTC.GetId() ) self.Bind( wx.EVT_MENU, self.OnGraphical, id = self.menuGraphical.GetId() ) self.Bind( wx.EVT_MENU, self.OnNumerical, id = self.menuNumerical.GetId() ) self.Bind( wx.EVT_MENU, self.OnSensorList, id = self.menuSensorList.GetId() ) self.Bind( wx.EVT_MENU, self.OnQuit, id = self.menuQuit.GetId() ) self.Bind( wx.EVT_MENU, self.ToggleStatusBar, id = self.menuStatus.GetId() ) self.Bind( wx.EVT_MENU, self.OnAbout, id = self.menuAbout.GetId() ) self.Bind( wx.EVT_MENU, self.OnSerial, id = self.menuSerial.GetId() ) self.Bind(wx.EVT_TIMER, self.UpdateTime, self.timer) self.Bind(wx.EVT_TIMER, self.UpdateDTC, self.timerDTC) #panels self.settingsesorpanel = SettitingSensorPanel(self) self.settingalarmpanel = SettingAlarmsPanel(self) self.settingserialpanel = SettingSerialPanel(self) self.settingrecordpanel = SettingRecordPanel(self) self.modegraphicalpanel = ModeGraphicalPanel(self) self.dtcpanel = DTCsPanel(self) self.recordspanel = RecordsPanel(self) self.modelistpanel = ModeListPanel(self) self.cfg = wx.Config('DTCs Settings') if self.cfg.Exists('refresh'): #port baudrate databits parity stop bits refreshtime = self.cfg.ReadInt('refresh') autodtc = self.cfg.ReadInt('autodtc') if autodtc == 1: self.timerDTC.Start(refreshtime*1000) else: self.timerDTC.Stop() else: autodtc = 0
def OnContextMenu(self, event): """Ouverture du menu contextuel """ ID = None if len(self.Selection()) > 0: ID = self.Selection()[0].IDfamille # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Ouverture fiche famille item = wx.MenuItem(menuPop, 10, _(u"Ouvrir la fiche famille")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Famille.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.OuvrirFicheFamille, id=10) if ID == None: item.Enable(False) menuPop.AppendSeparator() # Item Tout cocher item = wx.MenuItem(menuPop, 70, _(u"Tout cocher")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Cocher.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.CocheTout, id=70) # Item Tout décocher item = wx.MenuItem(menuPop, 80, _(u"Tout décocher")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Decocher.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.CocheRien, id=80) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=40) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=50) menuPop.AppendSeparator() # Item Export Texte item = wx.MenuItem(menuPop, 600, _(u"Exporter au format Texte")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Texte2.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportTexte, id=600) # Item Export Excel item = wx.MenuItem(menuPop, 700, _(u"Exporter au format Excel")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Excel.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportExcel, id=700) self.PopupMenu(menuPop) menuPop.Destroy()
def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False ID = self.Selection()[0].IDinscription # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Modifier item = wx.MenuItem(menuPop, 10, _(u"Ajouter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ajouter.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Ajouter, id=10) # Item Ajouter item = wx.MenuItem(menuPop, 20, _(u"Modifier")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) if noSelection == True: item.Enable(False) # Item Supprimer item = wx.MenuItem(menuPop, 30, _(u"Supprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Supprimer.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Supprimer, id=30) if noSelection == True: item.Enable(False) menuPop.AppendSeparator() # Item Imprimer item = wx.MenuItem(menuPop, 91, _(u"Imprimer l'inscription")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ImprimerPDF, id=91) if noSelection == True: item.Enable(False) # Item Envoyer par Email item = wx.MenuItem(menuPop, 92, _(u"Envoyer l'inscription par Email")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Emails_exp.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.EnvoyerEmail, id=92) if noSelection == True: item.Enable(False) # Item Editer Confirmation d'inscription # item = wx.MenuItem(menuPop, 60, _(u"Editer une confirmation d'inscription (PDF)")) # bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) # item.SetBitmap(bmp) # menuPop.AppendItem(item) # self.Bind(wx.EVT_MENU, self.EditerConfirmation, id=60) # if noSelection == True : item.Enable(False) menuPop.AppendSeparator() # Génération automatique des fonctions standards self.GenerationContextMenu(menuPop, titre=_(u"Liste des inscriptions")) self.PopupMenu(menuPop) menuPop.Destroy()
def InitUI(self): self.SetSize((720, 600)) self.SetTitle('Test Seq Tools') menubar = wx.MenuBar() fileMenu = wx.Menu() analysis = wx.Menu() setting = wx.Menu() help = wx.Menu() fileMenu.Append(101, '&Open', 'Open a new document') fileMenu.Append(102, '&Save', 'Save the document') fileMenu.AppendSeparator() quit = wx.MenuItem(fileMenu, APP_EXIT, '&Quit\tCtrl+Q') fileMenu.Append(quit) self.Bind(wx.EVT_MENU, self.OnQuit, id=APP_EXIT) analysis.Append(201, 'Find motif', 'find subsequence motif', kind=wx.ITEM_NORMAL) analysis.Append(202, 'GC content', 'calculation GC percentage', kind=wx.ITEM_NORMAL) analysis.Append(203, 'Reverse Comp', 'reverse complement seq', kind=wx.ITEM_NORMAL) #analysis.Append(203, 'Reverse Comp', 'reverse complement seq', kind=wx.ITEM_CHECK) help.Append(301, 'Usage', '', kind=wx.ITEM_NORMAL) help.Append(302, 'version', '', kind=wx.ITEM_NORMAL) menubar.Append(fileMenu, '&File') menubar.Append(analysis, '&Analysis') menubar.Append(setting, '&Setting') menubar.Append(help, '&Help') self.SetMenuBar(menubar) self.Centre() self.seq_names = wx.TextCtrl(self, style=wx.TE_MULTILINE, size=(200, 500)) self.contents = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.HSCROLL) #contents=wx.StaticText(frame, label="Colored text") #self.contents.SetForegroundColour((25,70,255)) # set text color self.contents.SetBackgroundColour( (119, 136, 153)) # set text back color hbox = wx.BoxSizer() hbox.Add(self.seq_names, proportion=1, flag=wx.EXPAND) h1box = wx.BoxSizer(wx.HORIZONTAL) ## VERTICAL is another option h1box.Add(hbox, proportion=0, flag=wx.EXPAND | wx.BOTTOM | wx.LEFT, border=5) h1box.Add(self.contents, proportion=1, flag=wx.EXPAND | wx.BOTTOM | wx.RIGHT | wx.TE_RICH2, border=5) self.SetSizer(h1box) self.Bind(wx.EVT_MENU, self.openfile, id=101) ## if add Button and bind Event to Button, use follow procedures # self.openButton=wx.Button(self, 2, label="open",pos=(225,290),size=(80,25)) # self.openButton.Bind(wx.EVT_BUTTON, self.openfile, id = 2) self.Bind(wx.EVT_MENU, self.Analyze_Motif, id=201)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Bowling Scoring System", pos = wx.DefaultPosition, size = wx.Size( 1220,800 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.VERTICAL ) bSizer2 = wx.BoxSizer( wx.VERTICAL ) bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText121 = wx.StaticText( self, wx.ID_ANY, u"Players", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText121.Wrap( -1 ) bSizer4.Add( self.m_staticText121, 0, wx.ALL, 5 ) bSizer4.Add( ( 80, 0), 1, wx.EXPAND, 5 ) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) bSizer4.Add( self.m_staticText2, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) bSizer4.Add( self.m_staticText3, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"3", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText6.Wrap( -1 ) bSizer4.Add( self.m_staticText6, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"4", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText7.Wrap( -1 ) bSizer4.Add( self.m_staticText7, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"5", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText8.Wrap( -1 ) bSizer4.Add( self.m_staticText8, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, u"6", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText9.Wrap( -1 ) bSizer4.Add( self.m_staticText9, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText10 = wx.StaticText( self, wx.ID_ANY, u"7", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText10.Wrap( -1 ) bSizer4.Add( self.m_staticText10, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, u"8", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText11.Wrap( -1 ) bSizer4.Add( self.m_staticText11, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText12 = wx.StaticText( self, wx.ID_ANY, u"9", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText12.Wrap( -1 ) bSizer4.Add( self.m_staticText12, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText13 = wx.StaticText( self, wx.ID_ANY, u"10", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText13.Wrap( -1 ) bSizer4.Add( self.m_staticText13, 0, wx.ALL, 5 ) bSizer4.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText131 = wx.StaticText( self, wx.ID_ANY, u"Total", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText131.Wrap( -1 ) bSizer4.Add( self.m_staticText131, 0, wx.ALL, 5 ) bSizer2.Add( bSizer4, 0, wx.LEFT, 5 ) bSizer3 = wx.BoxSizer( wx.VERTICAL ) self.m_scrolledWindow2 = wx.ScrolledWindow( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.VSCROLL ) self.m_scrolledWindow2.SetScrollRate( 5, 5 ) self.bSizer8 = wx.BoxSizer( wx.VERTICAL ) self.m_scrolledWindow2.SetSizer( self.bSizer8 ) self.m_scrolledWindow2.Layout() self.bSizer8.Fit( self.m_scrolledWindow2 ) bSizer3.Add( self.m_scrolledWindow2, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, 0 ) bSizer2.Add( bSizer3, 1, wx.EXPAND, 5 ) bSizer7 = wx.BoxSizer( wx.HORIZONTAL ) self.m_radioBtn1 = wx.RadioButton( self, wx.ID_ANY, u"-", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn1, 0, wx.ALL, 5 ) self.m_radioBtn2 = wx.RadioButton( self, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn2, 0, wx.ALL, 5 ) self.m_radioBtn3 = wx.RadioButton( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn3, 0, wx.ALL, 5 ) self.m_radioBtn4 = wx.RadioButton( self, wx.ID_ANY, u"3", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn4, 0, wx.ALL, 5 ) self.m_radioBtn5 = wx.RadioButton( self, wx.ID_ANY, u"4", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn5, 0, wx.ALL, 5 ) self.m_radioBtn6 = wx.RadioButton( self, wx.ID_ANY, u"5", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn6, 0, wx.ALL, 5 ) self.m_radioBtn7 = wx.RadioButton( self, wx.ID_ANY, u"6", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn7, 0, wx.ALL, 5 ) self.m_radioBtn8 = wx.RadioButton( self, wx.ID_ANY, u"7", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn8, 0, wx.ALL, 5 ) self.m_radioBtn9 = wx.RadioButton( self, wx.ID_ANY, u"8", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn9, 0, wx.ALL, 5 ) self.m_radioBtn10 = wx.RadioButton( self, wx.ID_ANY, u"9", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn10, 0, wx.ALL, 5 ) self.m_radioBtn11 = wx.RadioButton( self, wx.ID_ANY, u"X", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn11, 0, wx.ALL, 5 ) self.m_radioBtn12 = wx.RadioButton( self, wx.ID_ANY, u"/", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer7.Add( self.m_radioBtn12, 0, wx.ALL, 5 ) bSizer2.Add( bSizer7, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.EnterButton = wx.Button( self, wx.ID_ANY, u"Enter Score", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.EnterButton, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 ) bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) self.Layout() self.m_menubar1 = wx.MenuBar( 0 ) self.m_menu1 = wx.Menu() self.m_menuItem2 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"Generate Rankings"+ u"\t" + u"CTRL+G", wx.EmptyString, wx.ITEM_NORMAL ) self.m_menu1.Append( self.m_menuItem2 ) self.m_menuItem1 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"Quit"+ u"\t" + u"CTRL+Q", wx.EmptyString, wx.ITEM_NORMAL ) self.m_menu1.Append( self.m_menuItem1 ) self.m_menubar1.Append( self.m_menu1, u"File" ) self.SetMenuBar( self.m_menubar1 ) self.Centre( wx.BOTH ) # Connect Events self.Bind( wx.EVT_CLOSE, self.ExitProgram ) self.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.Bind( wx.EVT_SHOW, self.OnShow ) self.m_scrolledWindow2.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn1.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn1.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn2.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn2.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn3.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn3.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn4.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn4.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn5.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn5.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn6.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn6.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn7.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn7.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn8.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn8.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn9.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn9.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn10.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn10.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn11.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn11.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.m_radioBtn12.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_radioBtn12.Bind( wx.EVT_RADIOBUTTON, self.UpdateCurrentScoreInput ) self.EnterButton.Bind( wx.EVT_BUTTON, self.EnterScore ) self.EnterButton.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.m_menubar1.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown ) self.Bind( wx.EVT_MENU, self.GenerateReport, id = self.m_menuItem2.GetId() ) self.Bind( wx.EVT_MENU, self.ExitProgram, id = self.m_menuItem1.GetId() )
def __init_wx(self): self.label_step1 = wx.StaticText(self, wx.ID_ANY, self.lang["step_1_select_medium"]) self.radio_device = wx.RadioButton(self, wx.ID_ANY, self.lang["physical_device"]) self.combo_device = wx.ComboBox(self, wx.ID_ANY, choices=getDevices(), style=wx.CB_DROPDOWN) self.radio_iso = wx.RadioButton(self, wx.ID_ANY, self.lang["iso_image"]) self.combo_iso = wx.ComboBox(self, wx.ID_ANY, choices=self.lastIsos, style=wx.CB_DROPDOWN) self.button_iso_open = wx.Button(self, wx.ID_ANY, self.lang["open"]) self.sl1 = wx.StaticLine(self, wx.ID_ANY, style=wx.EXPAND) self.label_step2 = wx.StaticText(self, wx.ID_ANY, self.lang["step_2_select_tracks"]) self.button_loadDisk = wx.Button(self, wx.ID_ANY, self.lang["read_tracks"]) self.trackList = CheckListCtrl(self) self.trackList.InsertColumn(0, self.lang["no"], width=50) self.trackList.InsertColumn(1, self.lang["list_title"]) self.trackList.InsertColumn(2, self.lang["album"]) self.trackList.InsertColumn(3, self.lang["interpreter"]) self.trackList.InsertColumn(4, self.lang["duration"]) self.trackList.InsertColumn(5, self.lang["year"]) self.sl2 = wx.StaticLine(self, wx.ID_ANY, style=wx.EXPAND) self.label_step3 = wx.StaticText(self, wx.ID_ANY, self.lang["step_3_options"]) self.label_temp = wx.StaticText(self, wx.ID_ANY, self.lang["temp_path"]) self.combo_temp = wx.ComboBox(self, wx.ID_ANY, choices=self.lastTmps, style=wx.CB_DROPDOWN) self.button_temp_open = wx.Button(self, wx.ID_ANY, self.lang["open"]) self.label_out = wx.StaticText(self, wx.ID_ANY, self.lang["out_path"]) self.combo_out = wx.ComboBox(self, wx.ID_ANY, choices=self.lastOuts, style=wx.CB_DROPDOWN) self.button_out_open = wx.Button(self, wx.ID_ANY, self.lang["open"]) self.label_container = wx.StaticText(self, wx.ID_ANY, self.lang["container"]) self.choice_container = wx.Choice(self, wx.ID_ANY, choices=[ "MP3 (.mp3)", "MP2 (.mp2)", "Wave (.wav)", "Vorbis (.ogg)", "flac (.flac)" ]) self.radio_onefile = wx.CheckBox(self, wx.ID_ANY, self.lang["connect_tracks"]) self.button_start = wx.Button(self, wx.ID_ANY, self.lang["start"]) self.combo_temp.SetValue(tempfile.gettempdir()) self.combo_out.SetValue(os.path.join(self.userHomePath, "CD")) self.menubar = wx.MenuBar() self.file = wx.Menu() self.close = wx.MenuItem(self.file, wx.NewId(), self.lang["close"], "", wx.ITEM_NORMAL) self.file.AppendItem(self.close) self.menubar.Append(self.file, self.lang["file"]) self.language = wx.Menu() self.german = wx.MenuItem(self.language, wx.NewId(), "Deutsch", "", wx.ITEM_RADIO) self.language.AppendItem(self.german) self.english = wx.MenuItem(self.language, wx.NewId(), "English", "", wx.ITEM_RADIO) self.language.AppendItem(self.english) self.menubar.Append(self.language, "Language") self.about = wx.Menu() self.ueber = wx.MenuItem(self.about, wx.NewId(), self.lang["about"], "", wx.ITEM_NORMAL) self.about.AppendItem(self.ueber) self.menubar.Append(self.about, self.lang["about"]) self.SetMenuBar(self.menubar) self.german.Check(self.langcode == "de") self.english.Check(self.langcode == "en") self.__set_properties() self.__do_layout() self.__init_groups() self.showGroup("step1") self.showGroup("read") self.hideGroup("step2") self.hideGroup("step3") self.radio_device.SetValue(True) self.sel_device(None) self.Bind(wx.EVT_RADIOBUTTON, self.sel_device, self.radio_device) self.Bind(wx.EVT_RADIOBUTTON, self.sel_iso, self.radio_iso) self.Bind(wx.EVT_TEXT, self.changed_medium, self.combo_device) self.Bind(wx.EVT_COMBOBOX, self.changed_medium, self.combo_device) self.Bind(wx.EVT_TEXT, self.changed_medium, self.combo_iso) self.Bind(wx.EVT_COMBOBOX, self.changed_medium, self.combo_iso) self.Bind(wx.EVT_BUTTON, self.loadDisk, self.button_loadDisk) self.Bind(wx.EVT_BUTTON, self.open_iso, self.button_iso_open) self.Bind(wx.EVT_BUTTON, self.open_tmp, self.button_temp_open) self.Bind(wx.EVT_BUTTON, self.open_out, self.button_out_open) self.Bind(wx.EVT_BUTTON, self.start, self.button_start) self.Bind(wx.EVT_MENU, self.exit, self.close) self.Bind(wx.EVT_MENU, self.lang_german, self.german) self.Bind(wx.EVT_MENU, self.lang_english, self.english) self.Bind(wx.EVT_MENU, self.show_ueber, self.ueber) self.Bind(wx.EVT_CLOSE, self.exit)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.Size(1485, 851), style=wx.DEFAULT_FRAME_STYLE | wx.MINIMIZE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) bSizer1 = wx.BoxSizer(wx.HORIZONTAL) self.m_splitter1 = wx.SplitterWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_3D) self.m_splitter1.Bind(wx.EVT_IDLE, self.m_splitter1OnIdle) self.panel_draw = wx.Panel(self.m_splitter1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer6 = wx.BoxSizer(wx.VERTICAL) self.image_draw = wx.StaticBitmap(self.panel_draw, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL) self.image_draw.SetForegroundColour(wx.Colour(255, 255, 255)) self.image_draw.SetBackgroundColour(wx.Colour(255, 255, 255)) bSizer6.Add(self.image_draw, 1, wx.ALL | wx.EXPAND, 5) self.panel_draw.SetSizer(bSizer6) self.panel_draw.Layout() bSizer6.Fit(self.panel_draw) self.m_panel2 = wx.Panel(self.m_splitter1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer7 = wx.BoxSizer(wx.VERTICAL) self.splitter_edit_object = wx.SplitterWindow(self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_3D) self.splitter_edit_object.Bind(wx.EVT_IDLE, self.splitter_edit_objectOnIdle) self.m_panel3 = wx.Panel(self.splitter_edit_object, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer8 = wx.BoxSizer(wx.VERTICAL) self.m_notebook1 = wx.Notebook(self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.m_panel6 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer61 = wx.BoxSizer(wx.VERTICAL) self.tree_layers = wx.dataview.DataViewCtrl(self.m_panel6, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) bSizer61.Add(self.tree_layers, 1, wx.ALL | wx.EXPAND, 5) self.m_panel6.SetSizer(bSizer61) self.m_panel6.Layout() bSizer61.Fit(self.m_panel6) self.m_notebook1.AddPage(self.m_panel6, u"Layers", False) bSizer8.Add(self.m_notebook1, 1, wx.EXPAND | wx.ALL, 5) self.m_panel3.SetSizer(bSizer8) self.m_panel3.Layout() bSizer8.Fit(self.m_panel3) self.panel_edit_object = wx.Panel(self.splitter_edit_object, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) self.splitter_edit_object.SplitHorizontally(self.m_panel3, self.panel_edit_object, 294) bSizer7.Add(self.splitter_edit_object, 1, wx.EXPAND, 5) self.m_panel2.SetSizer(bSizer7) self.m_panel2.Layout() bSizer7.Fit(self.m_panel2) self.m_splitter1.SplitVertically(self.panel_draw, self.m_panel2, 1191) bSizer1.Add(self.m_splitter1, 1, wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() self.status_bar = self.CreateStatusBar(3, wx.STB_SIZEGRIP, wx.ID_ANY) self.menu = wx.MenuBar(0) self.menu_file = wx.Menu() self.menu_file_save = wx.MenuItem(self.menu_file, wx.ID_ANY, u"Save", wx.EmptyString, wx.ITEM_NORMAL) self.menu_file.Append(self.menu_file_save) self.menu_file_save_as = wx.MenuItem(self.menu_file, wx.ID_ANY, u"Save as ...", wx.EmptyString, wx.ITEM_NORMAL) self.menu_file.Append(self.menu_file_save_as) self.menu.Append(self.menu_file, u"File") self.menu_draw = wx.Menu() self.menu_draw_pad = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Pad", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_pad) self.menu_draw_pad_row = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Pad row", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_pad_row) self.menu_draw_pad_array = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Pad array", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_pad_array) self.menu_draw_polyline = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Polyline", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_polyline) self.menu_draw_arc = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Arc", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_arc) self.menu_draw_circle = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Circle", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_circle) self.menu_draw_text = wx.MenuItem(self.menu_draw, wx.ID_ANY, u"Text", wx.EmptyString, wx.ITEM_NORMAL) self.menu_draw.Append(self.menu_draw_text) self.menu.Append(self.menu_draw, u"Draw") self.menu_tool = wx.Menu() self.menu_tool_dimension = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Dimension", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_dimension) self.menu_tool_angle = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Angle", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_angle) self.menu_tool_grid = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Grid", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_grid) self.menu_tool_vertical = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Vertical", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_vertical) self.menu_tool_horizontal = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Horizontal", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_horizontal) self.menu_tool_line = wx.MenuItem(self.menu_tool, wx.ID_ANY, u"Line", wx.EmptyString, wx.ITEM_NORMAL) self.menu_tool.Append(self.menu_tool_line) self.menu.Append(self.menu_tool, u"Tool") self.menu_zoom = wx.Menu() self.menu_zoom_reset = wx.MenuItem(self.menu_zoom, wx.ID_ANY, u"Reset", wx.EmptyString, wx.ITEM_NORMAL) self.menu_zoom.Append(self.menu_zoom_reset) self.menu_zoom_in = wx.MenuItem(self.menu_zoom, wx.ID_ANY, u"Zoom in", wx.EmptyString, wx.ITEM_NORMAL) self.menu_zoom.Append(self.menu_zoom_in) self.menu_zoom_out = wx.MenuItem(self.menu_zoom, wx.ID_ANY, u"Zoom out", wx.EmptyString, wx.ITEM_NORMAL) self.menu_zoom.Append(self.menu_zoom_out) self.menu.Append(self.menu_zoom, u"Zoom") self.menu_edit = wx.Menu() self.menu_edit_duplicate = wx.MenuItem(self.menu_edit, wx.ID_ANY, u"Duplicate", wx.EmptyString, wx.ITEM_NORMAL) self.menu_edit.Append(self.menu_edit_duplicate) self.menu_edit_move = wx.MenuItem(self.menu_edit, wx.ID_ANY, u"Move", wx.EmptyString, wx.ITEM_NORMAL) self.menu_edit.Append(self.menu_edit_move) self.menu_edit_remove = wx.MenuItem(self.menu_edit, wx.ID_ANY, u"Remove", wx.EmptyString, wx.ITEM_NORMAL) self.menu_edit.Append(self.menu_edit_remove) self.menu_edit_rotate = wx.MenuItem(self.menu_edit, wx.ID_ANY, u"Rotate", wx.EmptyString, wx.ITEM_NORMAL) self.menu_edit.Append(self.menu_edit_rotate) self.menu.Append(self.menu_edit, u"Edit") self.SetMenuBar(self.menu) self.Centre(wx.BOTH) # Connect Events self.image_draw.Bind(wx.EVT_LEFT_DCLICK, self.onImageDrawLeftDClick) self.image_draw.Bind(wx.EVT_LEFT_DOWN, self.onImageDrawLeftDown) self.image_draw.Bind(wx.EVT_LEFT_UP, self.onImageDrawLeftUp) self.image_draw.Bind(wx.EVT_MIDDLE_DCLICK, self.onImageDrawMiddleDClick) self.image_draw.Bind(wx.EVT_MIDDLE_DOWN, self.onImageDrawMiddleDown) self.image_draw.Bind(wx.EVT_MIDDLE_UP, self.onImageDrawMiddleUp) self.image_draw.Bind(wx.EVT_MOTION, self.onImageDrawMotion) self.image_draw.Bind(wx.EVT_LEFT_DOWN, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_LEFT_UP, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MIDDLE_DOWN, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MIDDLE_UP, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_RIGHT_DOWN, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_RIGHT_UP, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MOTION, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_LEFT_DCLICK, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MIDDLE_DCLICK, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_RIGHT_DCLICK, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_LEAVE_WINDOW, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_ENTER_WINDOW, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MOUSEWHEEL, self.onImageDrawMouseEvents) self.image_draw.Bind(wx.EVT_MOUSEWHEEL, self.onImageDrawMouseWheel) self.image_draw.Bind(wx.EVT_RIGHT_DCLICK, self.onImageDrawRightDClick) self.image_draw.Bind(wx.EVT_RIGHT_DOWN, self.onImageDrawRightDown) self.image_draw.Bind(wx.EVT_RIGHT_UP, self.onImageDrawRightUp) self.image_draw.Bind(wx.EVT_SIZE, self.onImageDrawSize) self.Bind(wx.EVT_MENU, self.onMenuFileSaveSelection, id=self.menu_file_save.GetId()) self.Bind(wx.EVT_MENU, self.onMenuFileSaveAsSelection, id=self.menu_file_save_as.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawPadSelection, id=self.menu_draw_pad.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawPadRowSelection, id=self.menu_draw_pad_row.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawPadArraySelection, id=self.menu_draw_pad_array.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawPolylineSelection, id=self.menu_draw_polyline.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawArcSelection, id=self.menu_draw_arc.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawCircleSelection, id=self.menu_draw_circle.GetId()) self.Bind(wx.EVT_MENU, self.onMenuDrawTextSelection, id=self.menu_draw_text.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolDimensionSelection, id=self.menu_tool_dimension.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolAngleSelection, id=self.menu_tool_angle.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolGridSelection, id=self.menu_tool_grid.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolVerticalSelection, id=self.menu_tool_vertical.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolHorizontalSelection, id=self.menu_tool_horizontal.GetId()) self.Bind(wx.EVT_MENU, self.onMenuToolLineSelection, id=self.menu_tool_line.GetId()) self.Bind(wx.EVT_MENU, self.onMenuZoomResetSelection, id=self.menu_zoom_reset.GetId()) self.Bind(wx.EVT_MENU, self.onMenuZoomInSelection, id=self.menu_zoom_in.GetId()) self.Bind(wx.EVT_MENU, self.onMenuZoomOutSelection, id=self.menu_zoom_out.GetId()) self.Bind(wx.EVT_MENU, self.onMenuEditDuplicateSelection, id=self.menu_edit_duplicate.GetId()) self.Bind(wx.EVT_MENU, self.onMenuEditMoveSelection, id=self.menu_edit_move.GetId()) self.Bind(wx.EVT_MENU, self.onMenuEditRemoveSelection, id=self.menu_edit_remove.GetId()) self.Bind(wx.EVT_MENU, self.onMenuEditRotateSelection, id=self.menu_edit_rotate.GetId())
def create_menu_item(menu, label, func=None): item = wx.MenuItem(menu, -1, label) if func is not None: menu.Bind(wx.EVT_MENU, func, id=item.GetId()) menu.Append(item) return item
def CreateRightClickMenu(self): self._rmenu = wx.Menu() item = wx.MenuItem(self._rmenu, MENU_EDIT_DELETE_PAGE, _("Close Tab\tCtrl+F4"), _("Close Tab")) self._rmenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.__OnClosePage, item)
def __init__(self, parent): wx.Menu.__init__(self) parent = parent.GetParent() newDiagram = wx.MenuItem(self, ID_NEW, _('New'), _("Create a new tab diagram")) detachDiagram = wx.MenuItem(self, ID_DETACH_DIAGRAM, _('Detach'), _("Detach the tab to a frame window")) zoomIn = wx.MenuItem(self, ID_ZOOMIN_DIAGRAM, _('Zoom'), _("Zoom in")) zoomOut = wx.MenuItem(self, ID_ZOOMOUT_DIAGRAM, _('UnZoom'), _("Zoom out")) annuleZoom = wx.MenuItem(self, ID_UNZOOM_DIAGRAM, _('AnnuleZoom'), _("Normal view")) checkDiagram = wx.MenuItem(self, ID_CHECK_DIAGRAM, _('Debugger\tF4'), _("Check DEVS master model of diagram")) simulationDiagram = wx.MenuItem(self, ID_SIM_DIAGRAM, _('&Simulate\tF5'), _("Perform the simulation")) constantsDiagram = wx.MenuItem(self, ID_CONST_DIAGRAM, _('Add constants'), _("Loading constants parameters")) priorityDiagram = wx.MenuItem(self, ID_PRIORITY_DIAGRAM, _('Priority\tF3'), _("Priority for select function")) infoDiagram = wx.MenuItem( self, ID_INFO_DIAGRAM, _('Information'), _("Information about diagram (number of models, connections, etc)") ) clearDiagram = wx.MenuItem(self, ID_CLEAR_DIAGRAM, _('Clear'), _("Remove all components in diagram")) renameDiagram = wx.MenuItem(self, ID_RENAME_DIAGRAM, _('Rename'), _("Rename diagram")) closeDiagram = wx.MenuItem(self, ID_EXIT_DIAGRAM, _('&Close\tCtrl+D'), _("Close the tab")) newDiagram.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'new.png'))) detachDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'detach.png'))) zoomIn.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'zoom+.png'))) zoomOut.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'zoom-.png'))) annuleZoom.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'no_zoom.png'))) checkDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'check_master.png'))) simulationDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'simulation.png'))) constantsDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'properties.png'))) priorityDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'priority.png'))) infoDiagram.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'info.png'))) clearDiagram.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'delete.png'))) renameDiagram.SetBitmap( wx.Bitmap(os.path.join(ICON_PATH, 'rename.png'))) closeDiagram.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH, 'close.png'))) self.AppendItem(newDiagram) self.AppendItem(renameDiagram) self.AppendItem(detachDiagram) self.AppendSeparator() self.AppendItem(zoomIn) self.AppendItem(zoomOut) self.AppendItem(annuleZoom) self.AppendSeparator() self.AppendItem(checkDiagram) self.AppendItem(simulationDiagram) self.AppendItem(constantsDiagram) self.AppendItem(priorityDiagram) self.AppendItem(infoDiagram) self.AppendSeparator() self.AppendItem(clearDiagram) self.AppendSeparator() self.AppendItem(closeDiagram) parent.Bind(wx.EVT_MENU, parent.OnNew, id=ID_NEW) parent.Bind(wx.EVT_MENU, parent.nb2.OnDetachPage, id=ID_DETACH_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.nb2.OnRenamePage, id=ID_RENAME_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnCheck, id=ID_CHECK_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnSimulation, id=ID_SIM_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnConstantsLoading, id=ID_CONST_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnPriorityGUI, id=ID_PRIORITY_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnInfoGUI, id=ID_INFO_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.nb2.OnClearPage, id=ID_CLEAR_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnZoom, id=ID_ZOOMIN_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.OnUnZoom, id=ID_ZOOMOUT_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.AnnuleZoom, id=ID_UNZOOM_DIAGRAM) parent.Bind(wx.EVT_MENU, parent.nb2.OnClosePage, id=ID_EXIT_DIAGRAM)
def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False ID = self.Selection()[0].IDresponsable # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Modifier item = wx.MenuItem(menuPop, 10, _(u"Ajouter")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ajouter.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Ajouter, id=10) menuPop.AppendSeparator() # Item Ajouter item = wx.MenuItem(menuPop, 20, _(u"Modifier")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) if noSelection == True: item.Enable(False) # Item Supprimer item = wx.MenuItem(menuPop, 30, _(u"Supprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Supprimer.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Supprimer, id=30) if noSelection == True: item.Enable(False) menuPop.AppendSeparator() # Item Par défaut item = wx.MenuItem(menuPop, 40, _(u"Définir comme responsable par défaut")) if noSelection == False: if self.Selection()[0].defaut == 1: bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ok.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.SetDefaut, id=40) if noSelection == True: item.Enable(False) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=40) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=50) self.PopupMenu(menuPop) menuPop.Destroy()
def __init__(self, parent): """ Constructor. """ wx.Menu.__init__(self) ### last child of tree and not empty directory (then, has OnDocumentation method) if not parent.ItemHasChildren(parent.GetSelection()) and hasattr( parent, 'OnItemDocumentation'): edit = wx.MenuItem(self, ID_EDIT_LIB, _('Edit'), _('Edit selected module')) rename = wx.MenuItem(self, ID_RENAME_LIB, _('Rename...'), _('Rename selected module')) doc = wx.MenuItem(self, wx.NewId(), _('Doc'), _('Documentation of selected library')) update = wx.MenuItem(self, ID_UPDATE_LIB, _('Update'), _('Update selected module')) edit.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'edit.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) rename.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'rename.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) doc.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'doc.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) update.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'db_refresh.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) self.AppendItem(edit) self.AppendItem(rename) self.AppendItem(doc) self.AppendItem(update) self.Bind( wx.EVT_MENU, parent.OnItemEdit, id=ID_EDIT_LIB) # attention a le mettre avant le popUpMenu self.Bind( wx.EVT_MENU, parent.OnItemRename, id=ID_RENAME_LIB) # attention a le mettre avant le popUpMenu self.Bind( wx.EVT_MENU, parent.OnItemDocumentation, id=doc.GetId()) # attention a le mettre avant le popUpMenu self.Bind( wx.EVT_MENU, parent.OnItemRefresh, id=ID_UPDATE_LIB) # attention a le mettre avant le popUpMenu else: new_model = wx.MenuItem(self, ID_NEW_MODEL_LIB, _('New Model'), _('Add new model to the selected library')) new_model.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'new.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) self.InsertItem(0, new_model) self.Bind(wx.EVT_MENU, parent.OnNewModel, id=ID_NEW_MODEL_LIB) ### menu for all item of tree delete = wx.MenuItem(self, ID_DELETE_LIB, _('Delete'), _('Delete selected library')) delete.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'db-.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) self.AppendItem(delete) self.Bind(wx.EVT_MENU, parent.OnDelete, id=ID_DELETE_LIB) # attention a le mettre avant le popUpMenu
def CreateMenuBar(self): self._menuBar = wx.MenuBar(wx.MB_DOCKABLE) self._fileMenu = wx.Menu() self._editMenu = wx.Menu() self._visualMenu = wx.Menu() item = wx.MenuItem(self._fileMenu, wx.ID_ANY, "&Close\tCtrl-Q", "Close demo window") self.Bind(wx.EVT_MENU, self.OnQuit, item) self._fileMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADD_PAGE, "New Page\tCtrl+N", "Add New Page") self.Bind(wx.EVT_MENU, self.OnAddPage, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_PAGE, "Delete Page\tCtrl+F4", "Delete Page") self.Bind(wx.EVT_MENU, self.OnDeletePage, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_ALL, "Delete All Pages", "Delete All Pages") self.Bind(wx.EVT_MENU, self.OnDeleteAll, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_SET_SELECTION, "Set Selection", "Set Selection") self.Bind(wx.EVT_MENU, self.OnSetSelection, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_FWD, "Advance Selection Forward", "Advance Selection Forward") self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionFwd, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_BACK, "Advance Selection Backward", "Advance Selection Backward") self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionBack, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_SET_ALL_TABS_SHAPE_ANGLE, "Set an inclination of tab header borders", "Set the shape of tab header") self.Bind(wx.EVT_MENU, self.OnSetAllPagesShapeAngle, item) self._visualMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_SET_PAGE_IMAGE_INDEX, "Set image index of selected page", "Set image index") self.Bind(wx.EVT_MENU, self.OnSetPageImage, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_SHOW_IMAGES, "Show Images", "Show Images", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnShowImages, item) self._editMenu.Append(item) styleMenu = wx.Menu() item = wx.MenuItem(styleMenu, MENU_USE_DEFAULT_STYLE, "Use Default Style", "Use VC71 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnDefaultStyle, item) styleMenu.Append(item) item = wx.MenuItem(styleMenu, MENU_USE_VC71_STYLE, "Use VC71 Style", "Use VC71 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnVC71Style, item) styleMenu.Append(item) item = wx.MenuItem(styleMenu, MENU_USE_VC8_STYLE, "Use VC8 Style", "Use VC8 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnVC8Style, item) styleMenu.Append(item) item = wx.MenuItem(styleMenu, MENU_USE_FANCY_STYLE, "Use Fancy Style", "Use Fancy Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnFancyStyle, item) styleMenu.Append(item) item = wx.MenuItem(styleMenu, MENU_USE_FF2_STYLE, "Use Firefox 2 Style", "Use Firefox 2 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnFF2Style, item) styleMenu.Append(item) item = wx.MenuItem(styleMenu, MENU_USE_RIBBON_STYLE, "Use Ribbon Style", "Use Ribbon Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnRibbonStyle, item) styleMenu.Append(item) self._visualMenu.Append(wx.ID_ANY, "Tabs Style", styleMenu) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_FROM, "Select fancy tab style 'from' colour", "Select fancy tab style 'from' colour") self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_TO, "Select fancy tab style 'to' colour", "Select fancy tab style 'to' colour") self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_BORDER, "Select fancy tab style 'border' colour", "Select fancy tab style 'border' colour") self._visualMenu.Append(item) self._editMenu.AppendSeparator() self.Bind(wx.EVT_MENU_RANGE, self.OnSelectColour, id=MENU_SELECT_GRADIENT_COLOUR_FROM, id2=MENU_SELECT_GRADIENT_COLOUR_BORDER) item = wx.MenuItem(self._editMenu, MENU_HIDE_ON_SINGLE_TAB, "Hide Page Container when only one Tab", "Hide Page Container when only one Tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.Append(item) item = wx.MenuItem( self._editMenu, MENU_HIDE_TABS, "Hide Tabs", "Hide Page Container allowing only keyboard navigation", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_NO_TABS_FOCUS, "No focus on notebook tabs", "No focus on notebook tabs, only pages", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_HIDE_NAV_BUTTONS, "Hide Navigation Buttons", "Hide Navigation Buttons", wx.ITEM_CHECK) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_HIDE_X, "Hide X Button", "Hide X Button", wx.ITEM_CHECK) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_SMART_TABS, "Smart tabbing", "Smart tabbing", wx.ITEM_CHECK) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnSmartTabs, item) item.Check(False) item = wx.MenuItem(self._editMenu, MENU_USE_DROP_ARROW_BUTTON, "Use drop down button for tab navigation", "Use drop down arrow for quick tab navigation", wx.ITEM_CHECK) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnDropDownArrow, item) item.Check(False) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_TILE_HORIZONTALLY, "Tile pages horizontally", "Tile all the panels in an horizontal sizer", wx.ITEM_RADIO) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item = wx.MenuItem(self._editMenu, MENU_TILE_VERTICALLY, "Tile pages vertically", "Tile all the panels in a vertical sizer", wx.ITEM_RADIO) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item = wx.MenuItem(self._editMenu, MENU_TILE_NONE, "No tiling", "No tiling, standard FlatNotebook behaviour", wx.ITEM_RADIO) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item.Check(True) self._editMenu.AppendSeparator() item = wx.MenuItem( self._editMenu, wx.ID_ANY, "Use custom page", "Shows a custom page when the main notebook has no pages left", wx.ITEM_CHECK) self._editMenu.Append(item) self.Bind(wx.EVT_MENU, self.OnCustomPanel, item) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_USE_MOUSE_MIDDLE_BTN, "Use Mouse Middle Button as 'X' button", "Use Mouse Middle Button as 'X' button", wx.ITEM_CHECK) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_DCLICK_CLOSES_TAB, "Mouse double click closes tab", "Mouse double click closes tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnDClickCloseTab, item) self._editMenu.Append(item) item.Check(False) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_USE_BOTTOM_TABS, "Use Bottoms Tabs", "Use Bottoms Tabs", wx.ITEM_CHECK) self._editMenu.Append(item) self.Bind(wx.EVT_MENU_RANGE, self.OnStyle, id=MENU_HIDE_X, id2=MENU_USE_BOTTOM_TABS) item = wx.MenuItem(self._editMenu, MENU_ENABLE_TAB, "Enable Tab", "Enable Tab") self.Bind(wx.EVT_MENU, self.OnEnableTab, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_DISABLE_TAB, "Disable Tab", "Disable Tab") self.Bind(wx.EVT_MENU, self.OnDisableTab, item) self._editMenu.Append(item) item = wx.MenuItem(self._editMenu, MENU_ENABLE_DRAG_N_DROP, "Enable Drag And Drop of Tabs", "Enable Drag And Drop of Tabs", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnEnableDrag, item) self._editMenu.Append(item) item.Check(False) item = wx.MenuItem( self._editMenu, MENU_ALLOW_FOREIGN_DND, "Enable Drag And Drop of Tabs from foreign notebooks", "Enable Drag And Drop of Tabs from foreign notebooks", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnAllowForeignDnd, item) self._editMenu.Append(item) item.Check(False) item = wx.MenuItem(self._visualMenu, MENU_DRAW_BORDER, "Draw Border around tab area", "Draw Border around tab area", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._visualMenu.Append(item) item.Check(True) item = wx.MenuItem(self._visualMenu, MENU_DRAW_TAB_X, "Draw X button On Active Tab", "Draw X button On Active Tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnDrawTabX, item) self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SET_ACTIVE_TAB_COLOUR, "Select Active Tab Colour", "Select Active Tab Colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SET_TAB_AREA_COLOUR, "Select Tab Area Colour", "Select Tab Area Colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SET_ACTIVE_TEXT_COLOUR, "Select active tab text colour", "Select active tab text colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_NONACTIVE_TEXT_COLOUR, "Select NON-active tab text colour", "Select NON-active tab text colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.Append(item) item = wx.MenuItem(self._visualMenu, MENU_GRADIENT_BACKGROUND, "Use Gradient Colouring for tab area", "Use Gradient Colouring for tab area", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnGradientBack, item) self._visualMenu.Append(item) item.Check(False) item = wx.MenuItem(self._visualMenu, MENU_COLOURFUL_TABS, "Colourful tabs", "Colourful tabs", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnColourfulTabs, item) self._visualMenu.Append(item) item.Check(False) help_menu = wx.Menu() item = wx.MenuItem(help_menu, wx.ID_ANY, "About...", "Shows The About Dialog") self.Bind(wx.EVT_MENU, self.OnAbout, item) help_menu.Append(item) self._menuBar.Append(self._fileMenu, "&File") self._menuBar.Append(self._editMenu, "&Edit") self._menuBar.Append(self._visualMenu, "&Tab Appearance") self._menuBar.Append(help_menu, "&Help") self.SetMenuBar(self._menuBar)
def __init__(self, shape, event): """ Constructor. """ import Core.Components.Container as Container wx.Menu.__init__(self) self.__canvas = event.GetEventObject() rotate_subMenu = wx.Menu() export_subMenu = wx.Menu() connectable_subMenu = wx.Menu() edit_subMenu = wx.Menu() edit = wx.MenuItem(self, ID_EDIT_SHAPE, _("Edit"), _("Edit the code")) editModel = wx.MenuItem(self, ID_EDIT_MODEL_SHAPE, _("Model"), _("Edit the model code")) editTest = wx.MenuItem(self, ID_TESTING_SHAPE, _("Tests"), _("Edit the tests code")) log = wx.MenuItem(self, ID_LOG_SHAPE, _("Log"), _("View log file")) copy = wx.MenuItem(self, ID_COPY_SHAPE, _("&Copy\tCtrl+C"), _("Copy the model")) paste = wx.MenuItem(self, ID_PASTE_SHAPE, _("&Paste\tCtrl+V"), _("Paste the model")) cut = wx.MenuItem(self, ID_CUT_SHAPE, _("&Cut\tCtrl+X"), _("Cut the model")) rotateR = wx.MenuItem(self, ID_RIGHT_ROTATE_SHAPE, _("&Right Rotate\tCtrl+R"), _("Rotate on the right")) rotateL = wx.MenuItem(self, ID_LEFT_ROTATE_SHAPE, _("&Left Rotate\tCtrl+L"), _("Rotate on the left")) delete = wx.MenuItem(self, ID_DELETE_SHAPE, _("Delete"), _("Delete the model")) lock = wx.MenuItem(self, ID_LOCK_SHAPE, _("Lock"), _("Lock the link")) unlock = wx.MenuItem(self, ID_UNLOCK_SHAPE, _("Unlock"), _("Unlock the link")) export = wx.MenuItem(self, ID_EXPORT_SHAPE, _("Export"), _("Export the model")) exportAMD = wx.MenuItem(self, ID_EXPORT_AMD_SHAPE, _("AMD"), _("Model exported to a amd file")) exportCMD = wx.MenuItem(self, ID_EXPORT_CMD_SHAPE, _("CMD"), _("Model exported to a cmd file")) exportXML = wx.MenuItem(self, ID_EXPORT_XML_SHAPE, _("XML"), _("Model exported to a xml file")) exportJS = wx.MenuItem(self, ID_EXPORT_JS_SHAPE, _("JS"), _("Model exported to a js (join) file")) plugin = wx.MenuItem(self, ID_PLUGINS_SHAPE, _("Plugins"), _("Apply plugin to a model")) properties = wx.MenuItem(self, ID_PROPERTIES_SHAPE, _("Properties"), _("Edit the attributs")) edit.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'edit.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) editModel.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'edit.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) editTest.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'test.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) log.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'log.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) copy.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'copy.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) paste.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'paste.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) cut.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'cut.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) rotateL.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'rotateL.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) rotateR.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'rotateR.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) export.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'export.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) delete.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'delete.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) lock.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'lock.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) unlock.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'unlock.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) plugin.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'plugin.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) properties.SetBitmap( wx.Image(os.path.join(ICON_PATH_16_16, 'properties.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) if isinstance(shape, Container.ConnectionShape): self.AppendItem(delete) self.AppendItem(lock) self.AppendItem(unlock) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnDelete, id=ID_DELETE_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnLock, id=ID_LOCK_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnUnLock, id=ID_UNLOCK_SHAPE) elif isinstance(shape, Container.ResizeableNode): Delete_menu = self.AppendItem(delete) elif isinstance(shape, Container.Node): pass #port_number = wx.MenuItem(self, wx.NewId(), _("Enable port number"), _("Port number"),wx.ITEM_CHECK) #self.AppendItem(port_number) #rename_menu = self.AppendItem(rename) #self.__canvas.Bind(wx.EVT_MENU, shape.OnRename, id = ID_RENAME_SHAPE) else: if isinstance(shape, Container.CodeBlock) and shape.isAMD(): Edit_menu = self.AppendMenu(-1, _("Edit"), edit_subMenu) Edit_SubMenu1 = edit_subMenu.AppendItem(editModel) Edit_SubMenu2 = edit_subMenu.AppendItem(editTest) else: Edit_menu = self.AppendItem(edit) Log_menu = self.AppendItem(log) self.AppendSeparator() Copy_menu = self.AppendItem(copy) Paste_menu = self.AppendItem(paste) Cut_menu = self.AppendItem(cut) Lock_item = self.AppendItem(lock) UnLock_item = self.AppendItem(unlock) Rotate_SubMenu1 = rotate_subMenu.AppendItem(rotateR) Rotate_SubMenu2 = rotate_subMenu.AppendItem(rotateL) Rotate_menu = self.AppendMenu(ID_ROTATE_SHAPE, _("Rotate"), rotate_subMenu) self.AppendSeparator() # pour tout les model sur le canvas ormis les connection et le model que l'on veut connecter (la source) for i, item in enumerate( filter( lambda a: a != shape and not isinstance( a, Container.ConnectionShape), self.__canvas.GetDiagram().GetShapeList())): # on evite de proposer les connections suivante: iPort->iPort, oPort->oPort if (isinstance(shape, Container.iPort) and not isinstance(item, Container.iPort) ) or (isinstance(shape, Container.oPort) and not isinstance(item, Container.oPort)) or isinstance( shape, Container.Block): new_item = wx.MenuItem(connectable_subMenu, wx.NewId(), item.label) connectable_subMenu.AppendItem(new_item) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnConnectTo, id=new_item.GetId()) self.AppendMenu(-1, _('Connect to'), connectable_subMenu) if isinstance(shape, Container.CodeBlock): self.AppendSeparator() #Export_menu = self.AppendItem(export) Export_menu = self.AppendMenu(-1, _("Export"), export_subMenu) Export_SubMenu1 = export_subMenu.AppendItem(exportAMD) elif isinstance(shape, Container.ContainerBlock): self.AppendSeparator() Export_menu = self.AppendMenu(-1, _("Export"), export_subMenu) Export_SubMenu1 = export_subMenu.AppendItem(exportCMD) Export_SubMenu2 = export_subMenu.AppendItem(exportXML) Export_SubMenu3 = export_subMenu.AppendItem(exportJS) else: self.Enable(ID_EDIT_SHAPE, False) self.AppendSeparator() Delete_menu = self.AppendItem(delete) ### Plugin manager only for Block model if isinstance(shape, Container.CodeBlock) or isinstance( shape, Container.ContainerBlock): ### only for amd or cmd if shape.model_path != "": if ZipManager.Zip.HasPlugin(shape.model_path): self.AppendSeparator() Plugin_menu = self.AppendItem(plugin) self.__canvas.Bind(wx.EVT_MENU, shape.OnPluginsManager, id=ID_PLUGINS_SHAPE) self.AppendSeparator() Properties_menu = self.AppendItem(properties) self.Enable(ID_PASTE_SHAPE, not Container.clipboard == []) self.Enable(ID_LOG_SHAPE, shape.getDEVSModel() is not None) # binding events self.__canvas.Bind(wx.EVT_MENU, shape.OnRotateR, id=ID_RIGHT_ROTATE_SHAPE) self.__canvas.Bind(wx.EVT_MENU, shape.OnRotateL, id=ID_LEFT_ROTATE_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnDelete, id=ID_DELETE_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnCut, id=ID_CUT_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnCopy, id=ID_COPY_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnPaste, id=ID_PASTE_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnLock, id=ID_LOCK_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnUnLock, id=ID_UNLOCK_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnProperties, id=ID_PROPERTIES_SHAPE) # Codeblock specific binding if isinstance(shape, Container.CodeBlock): self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnEditor, id=ID_EDIT_MODEL_SHAPE) self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnLog, id=ID_LOG_SHAPE) self.__canvas.Bind(wx.EVT_MENU, shape.OnExport, id=ID_EXPORT_AMD_SHAPE) # AMD specific binding if shape.isAMD(): self.__canvas.Bind(wx.EVT_MENU, shape.OnTestEditor, id=ID_TESTING_SHAPE) else: self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnEditor, id=ID_EDIT_SHAPE) # ContainerBlock specific binding elif isinstance(shape, Container.ContainerBlock): self.__canvas.Bind(wx.EVT_MENU, self.__canvas.OnEditor, id=ID_EDIT_SHAPE) self.__canvas.Bind(wx.EVT_MENU, shape.OnExport, id=ID_EXPORT_CMD_SHAPE) self.__canvas.Bind(wx.EVT_MENU, shape.OnExport, id=ID_EXPORT_XML_SHAPE) self.__canvas.Bind(wx.EVT_MENU, shape.OnExport, id=ID_EXPORT_JS_SHAPE) if isinstance(shape, Container.ResizeableNode): shape.OnDeleteNode(event)
def __init__(self, *args, **kwds): # begin wxGlade: MyFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menu Bar self.frame_1_menubar = wx.MenuBar() self.SetMenuBar(self.frame_1_menubar) wxglade_tmp_menu = wx.Menu() self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit", "Exit", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendItem(self.Exit) self.frame_1_menubar.Append(wxglade_tmp_menu, "File") # Menu Bar end self.panel_1 = wx.Panel(self, -1) self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB") self.button_2 = wx.Button(self, ID_BUTTON_2, "USB") self.button_3 = wx.Button(self, ID_BUTTON_3, "AM") self.button_4 = wx.Button(self, ID_BUTTON_4, "CW") self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper") self.slider_fcutoff_hi = wx.Slider(self, ID_SLIDER_1, 0, -15798, 15799, style=wx.SL_HORIZONTAL | wx.SL_LABELS) self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower") self.slider_fcutoff_lo = wx.Slider(self, ID_SLIDER_2, 0, -15799, 15798, style=wx.SL_HORIZONTAL | wx.SL_LABELS) self.panel_5 = wx.Panel(self, -1) self.label_1 = wx.StaticText(self, -1, " Band\nCenter") self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "") self.panel_6 = wx.Panel(self, -1) self.panel_7 = wx.Panel(self, -1) self.panel_2 = wx.Panel(self, -1) self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq") self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000) self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100) self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol") self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500) self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20) self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time") self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew") self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd") self.panel_3 = wx.Panel(self, -1) self.label_2 = wx.StaticText(self, -1, "PGA ") self.panel_4 = wx.Panel(self, -1) self.panel_8 = wx.Panel(self, -1) self.panel_9 = wx.Panel(self, -1) self.panel_10 = wx.Panel(self, -1) self.panel_11 = wx.Panel(self, -1) self.panel_12 = wx.Panel(self, -1) self.__set_properties() self.__do_layout() # end wxGlade parser = OptionParser(option_class=eng_option) parser.add_option("", "--args", type="string", default="addr=''", help="Arguments for UHD device, [default=%default]") parser.add_option("", "--spec", type="string", default="A:0", help="UHD device subdev spec, [default=%default]") parser.add_option("-c", "--ddc-freq", type="eng_float", default=3.9e6, help="set Rx DDC frequency to FREQ", metavar="FREQ") parser.add_option( "-s", "--samp-rate", type="eng_float", default=256000, help="set sample rate (bandwidth) [default=%default]") parser.add_option("-a", "--audio_file", default="", help="audio output file", metavar="FILE") parser.add_option("-r", "--radio_file", default="", help="radio output file", metavar="FILE") parser.add_option("-i", "--input_file", default="", help="radio input file", metavar="FILE") parser.add_option( "-O", "--audio-output", type="string", default="", help="audio output device name. E.g., hw:0,0, /dev/dsp, or pulse") parser.add_option("", "--audio-rate", type="int", default=32000, help="audio output sample rate [default=%default]") (options, args) = parser.parse_args() self.usrp_center = options.ddc_freq self.input_rate = input_rate = options.samp_rate self.slider_range = input_rate * 0.9375 self.f_lo = self.usrp_center - (self.slider_range / 2) self.f_hi = self.usrp_center + (self.slider_range / 2) self.af_sample_rate = options.audio_rate self.tb = gr.top_block() # radio variables, initial conditions self.frequency = self.usrp_center # these map the frequency slider (0-6000) to the actual range self.f_slider_offset = self.f_lo self.f_slider_scale = 10000 / 250 self.spin_ctrl_1.SetRange(self.f_lo, self.f_hi) self.text_ctrl_1.SetValue(str(int(self.usrp_center))) self.slider_5.SetValue(0) self.AM_mode = False self.slider_3.SetValue( (self.frequency - self.f_slider_offset) / self.f_slider_scale) self.spin_ctrl_1.SetValue(int(self.frequency)) POWERMATE = True try: self.pm = powermate.powermate(self) except: sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n") POWERMATE = False if POWERMATE: powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate) powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton) self.active_button = 7 # command line options if options.audio_file == "": SAVE_AUDIO_TO_FILE = False else: SAVE_AUDIO_TO_FILE = True if options.radio_file == "": SAVE_RADIO_TO_FILE = False else: SAVE_RADIO_TO_FILE = True if options.input_file == "": self.PLAY_FROM_USRP = True else: self.PLAY_FROM_USRP = False if self.PLAY_FROM_USRP: self.src = uhd.usrp_source(options.args, stream_args=uhd.stream_args('fc32')) self.src.set_samp_rate(input_rate) self.src.set_subdev_spec(options.spec) self.input_rate = input_rate = self.src.get_samp_rate() self.src.set_center_freq(self.usrp_center, 0) self.tune_offset = 0 fir_decim = long(self.input_rate / self.af_sample_rate) rrate = self.af_sample_rate / (self.input_rate / float(fir_decim)) print "Actual Input Rate: ", self.input_rate print "FIR DECIM: ", fir_decim print "Remaining resampling: ", rrate print "Sampling Rate at Audio Sink: ", (self.input_rate / fir_decim) * rrate print "Request Rate at Audio Sink: ", self.af_sample_rate else: self.src = blocks.file_source(gr.sizeof_short, options.input_file) self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band # convert rf data in interleaved short int form to complex s2ss = blocks.stream_to_streams(gr.sizeof_short, 2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() src_f2c = blocks.float_to_complex() self.tb.connect(self.src, s2ss) self.tb.connect((s2ss, 0), s2f1) self.tb.connect((s2ss, 1), s2f2) self.tb.connect(s2f1, (src_f2c, 0)) self.tb.connect(s2f2, (src_f2c, 1)) fir_decim = long(self.input_rate / self.af_sample_rate) rrate = self.af_sample_rate / (self.input_rate / float(fir_decim)) print "FIR DECIM: ", fir_decim print "Remaining resampling: ", rrate print "Sampling Rate at Audio Sink: ", (self.input_rate / fir_decim) * rrate print "Request Rate at Audio Sink: ", self.af_sample_rate # save radio data to a file if SAVE_RADIO_TO_FILE: radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file) self.tb.connect(self.src, radio_file) # 2nd DDC xlate_taps = filter.firdes.low_pass ( \ 1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING ) self.xlate = filter.freq_xlating_fir_filter_ccf ( \ fir_decim, xlate_taps, self.tune_offset, input_rate ) nflts = 32 audio_coeffs = filter.firdes.complex_band_pass( nflts, # gain self.input_rate * nflts, # sample rate -3000.0, # low cutoff 0.0, # high cutoff 100.0, # transition filter.firdes.WIN_KAISER, 7.0) # window self.slider_fcutoff_hi.SetValue(0) self.slider_fcutoff_lo.SetValue(-3000) # Filter and resample based on actual radio's sample rate self.audio_filter = filter.pfb.arb_resampler_ccc(rrate, audio_coeffs) # Main +/- 16Khz spectrum display self.fft = fftsink2.fft_sink_c(self.panel_2, fft_size=512, sample_rate=self.af_sample_rate, average=True, size=(640, 240), baseband_freq=self.usrp_center) c2f = blocks.complex_to_float() # AM branch self.sel_am = blocks.multiply_const_cc(0) # the following frequencies turn out to be in radians/sample # analog.pll_refout_cc(alpha,beta,min_freq,max_freq) # suggested alpha = X, beta = .25 * X * X pll = analog.pll_refout_cc( .05, (2. * math.pi * 7.5e3 / self.af_sample_rate), (2. * math.pi * 6.5e3 / self.af_sample_rate)) self.pll_carrier_scale = blocks.multiply_const_cc(complex(10, 0)) am_det = blocks.multiply_cc() # these are for converting +7.5kHz to -7.5kHz # for some reason blocks.conjugate_cc() adds noise ?? c2f2 = blocks.complex_to_float() c2f3 = blocks.complex_to_float() f2c = blocks.float_to_complex() phaser1 = blocks.multiply_const_ff(1) phaser2 = blocks.multiply_const_ff(-1) # filter for pll generated carrier pll_carrier_coeffs = filter.firdes.complex_band_pass( 2.0, # gain self.af_sample_rate, # sample rate 7400, # low cutoff 7600, # high cutoff 100, # transition filter.firdes.WIN_HAMMING) # window self.pll_carrier_filter = filter.fir_filter_ccc(1, pll_carrier_coeffs) self.sel_sb = blocks.multiply_const_ff(1) combine = blocks.add_ff() #AGC sqr1 = blocks.multiply_ff() intr = filter.iir_filter_ffd([.004, 0], [0, .999]) offset = blocks.add_const_ff(1) agc = blocks.divide_ff() self.scale = blocks.multiply_const_ff(0.00001) dst = audio.sink(long(self.af_sample_rate), options.audio_output) if self.PLAY_FROM_USRP: self.tb.connect(self.src, self.xlate, self.fft) else: self.tb.connect(src_f2c, self.xlate, self.fft) self.tb.connect(self.xlate, self.audio_filter, self.sel_am, (am_det, 0)) self.tb.connect(self.sel_am, pll, self.pll_carrier_scale, self.pll_carrier_filter, c2f3) self.tb.connect((c2f3, 0), phaser1, (f2c, 0)) self.tb.connect((c2f3, 1), phaser2, (f2c, 1)) self.tb.connect(f2c, (am_det, 1)) self.tb.connect(am_det, c2f2, (combine, 0)) self.tb.connect(self.audio_filter, c2f, self.sel_sb, (combine, 1)) self.tb.connect(combine, self.scale) self.tb.connect(self.scale, (sqr1, 0)) self.tb.connect(self.scale, (sqr1, 1)) self.tb.connect(sqr1, intr, offset, (agc, 1)) self.tb.connect(self.scale, (agc, 0)) self.tb.connect(agc, blocks.null_sink(gr.sizeof_float)) self.tb.connect(c2f3, dst) if SAVE_AUDIO_TO_FILE: f_out = blocks.file_sink(gr.sizeof_short, options.audio_file) sc1 = blocks.multiply_const_ff(64000) f2s1 = blocks.float_to_short() self.tb.connect(agc, sc1, f2s1, f_out) self.tb.start() # left click to re-tune self.fft.win.plotter.Bind(wx.EVT_LEFT_DOWN, self.Click) # start a timer to check for web commands if WEB_CONTROL: self.timer = UpdateTimer(self, 1000) # every 1000 mSec, 1 Sec wx.EVT_BUTTON(self, ID_BUTTON_1, self.set_lsb) wx.EVT_BUTTON(self, ID_BUTTON_2, self.set_usb) wx.EVT_BUTTON(self, ID_BUTTON_3, self.set_am) wx.EVT_BUTTON(self, ID_BUTTON_4, self.set_cw) wx.EVT_BUTTON(self, ID_BUTTON_10, self.fwd) wx.EVT_BUTTON(self, ID_BUTTON_11, self.rew) wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_5, self.on_button) wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_6, self.on_button) wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_7, self.on_button) wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_8, self.on_button) wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_9, self.on_button) wx.EVT_SLIDER(self, ID_SLIDER_1, self.set_filter) wx.EVT_SLIDER(self, ID_SLIDER_2, self.set_filter) wx.EVT_SLIDER(self, ID_SLIDER_3, self.slide_tune) wx.EVT_SLIDER(self, ID_SLIDER_4, self.set_volume) wx.EVT_SLIDER(self, ID_SLIDER_5, self.set_pga) wx.EVT_SPINCTRL(self, ID_SPIN_1, self.spin_tune) wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
def InitUI(self): self.count = 0 font1 = wx.Font(pointSize=18, family=wx.DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_BOLD, faceName='Segoe UI') pnl = wx.Panel(self) vbox = wx.BoxSizer(wx.VERTICAL) vbox2 = wx.BoxSizer(wx.VERTICAL) vbox3 = wx.BoxSizer(wx.VERTICAL) hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox3 = wx.BoxSizer(wx.HORIZONTAL) hbox4 = wx.BoxSizer(wx.HORIZONTAL) #sizer1 = wx.GridBagSizer(4, 4) #self.setFont(font1) self.gauge = wx.Gauge(pnl, range=80, pos=(20, 120), size=(318, 28), style=wx.GA_HORIZONTAL) self.text = wx.TextCtrl(pnl, size=(740, 268), pos=(4, 29), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) self.text.SetFont(font1) #self.text = wx.TextCtrl(pnl, size=(-1,200),style=wx.EXPAND|wx.TE_MULTILINE) self.btn1 = wx.Button(pnl, label="Deploy Static Content: Zip/tar,tar.gz") self.Bind(wx.EVT_BUTTON, self.OnClick, self.btn1) hbox1.Add(self.gauge, proportion=10, flag=wx.ALIGN_CENTRE, border=20) # this is good one #hbox1.Add(self.text, proportion=1, flag=wx.ALIGN_CENTRE) hbox2.Add(self.btn1, proportion=1, flag=wx.RIGHT, border=10) vbox.Add(hbox2, proportion=1, flag=wx.ALIGN_CENTRE) vbox.Add(hbox1, proportion=1, flag=wx.EXPAND | wx.ALIGN_CENTRE) #self.gauge = wx.Gauge(pnl, range=80,pos=(20,220),size=(338, 20), style = wx.GA_SMOOTH) hbox3.Add(self.text, proportion=5, flag=wx.ALIGN_CENTRE, border=10) self.btn2 = wx.Button(pnl, label="Exit", size=(180, 50)) #self.btn2.setFont(font1) #sizer1.Add(self.btn2, pos=(400,400), flag=wx.RIGHT|wx.BOTTOM, border=5) hbox4.Add(self.btn2, flag=wx.LEFT | wx.BOTTOM, border=5) #hbox4.setFont(font1) vbox.Add(hbox4, flag=wx.ALIGN_CENTRE | wx.RIGHT, border=100) self.Bind(wx.EVT_BUTTON, self.OnClick2, self.btn2) #self.removeButton = wx.Button(self, label="Remove") #hbox1.Add(self.gauge, proportion=10, flag=wx.ALIGN_CENTRE, border=20) # this is good one pnl.SetSizer(vbox) menubar = wx.MenuBar() fileMenu = wx.Menu() newitem = wx.MenuItem(fileMenu, wx.ID_NEW, text="UAT", kind=wx.ITEM_NORMAL) #newitem.SetBitmap(wx.Bitmap("new.bmp")) fileMenu.Append(newitem) fileMenu.AppendSeparator() #editMenu = wx.Menu() #copyItem = wx.MenuItem(editMenu, 100,text = "copy",kind = wx.ITEM_NORMAL) #copyItem.SetBitmap(wx.Bitmap("copy.bmp")) #editMenu.Append(copyItem) #cutItem = wx.MenuItem(editMenu, 101,text = "cut",kind = wx.ITEM_NORMAL) #cutItem.SetBitmap(wx.Bitmap("cut.bmp")) #editMenu.Append(cutItem) #pasteItem = wx.MenuItem(editMenu, 102,text = "paste",kind = wx.ITEM_NORMAL) #pasteItem.SetBitmap(wx.Bitmap("paste.bmp")) #editMenu.Append(pasteItem) fileMenu.Append(wx.ID_ANY, "UAT2") #editMenu) fileMenu.AppendSeparator() #radio1 = wx.MenuItem(fileMenu, 200,text = "Radio1",kind = wx.ITEM_RADIO) #radio2 = wx.MenuItem(fileMenu, 300,text = "radio2",kind = wx.ITEM_RADIO) #fileMenu.Append(radio1) #fileMenu.Append(radio2) #fileMenu.AppendSeparator() fileMenu.AppendCheckItem(103, "PROD") quit = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+Q') fileMenu.Append(quit) menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.text = wx.TextCtrl(self, -1, style=wx.EXPAND | wx.TE_MULTILINE) self.Bind(wx.EVT_MENU, self.menuhandler) #self.SetSize((350, 250)) #self.progcolor = wx.GREEN self.Centre() self.Show(True)
def OnContextMenu(self, event): """Ouverture du menu contextuel """ if len(self.Selection()) == 0: noSelection = True else: noSelection = False # Création du menu contextuel menuPop = UTILS_Adaptations.Menu() # Item Modifier item = wx.MenuItem(menuPop, 20, _(u"Modifier la liste")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Modifier.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Modifier, id=20) menuPop.AppendSeparator() # Item Deplacer vers le haut item = wx.MenuItem(menuPop, 60, _(u"Déplacer vers le haut")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_haut.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Monter, id=60) if noSelection == True: item.Enable(False) # Item Déplacer vers le bas item = wx.MenuItem(menuPop, 70, _(u"Déplacer vers le bas")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Fleche_bas.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Descendre, id=70) if noSelection == True: item.Enable(False) menuPop.AppendSeparator() # Item Apercu avant impression item = wx.MenuItem(menuPop, 40, _(u"Aperçu avant impression")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Apercu, id=40) # Item Imprimer item = wx.MenuItem(menuPop, 50, _(u"Imprimer")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.Imprimer, id=50) menuPop.AppendSeparator() # Item Export Texte item = wx.MenuItem(menuPop, 600, _(u"Exporter au format Texte")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Texte2.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportTexte, id=600) # Item Export Excel item = wx.MenuItem(menuPop, 700, _(u"Exporter au format Excel")) bmp = wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Excel.png"), wx.BITMAP_TYPE_PNG) item.SetBitmap(bmp) menuPop.AppendItem(item) self.Bind(wx.EVT_MENU, self.ExportExcel, id=700) self.PopupMenu(menuPop) menuPop.Destroy()
def __init__(self): wx.Frame.__init__( self, None, wx.ID_ANY, u"Panity Editor", wx.DefaultPosition, wx.Size(800, 600), wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL | wx.EXPAND, "panity main frame") self.SetTitle("Panity") top_level_sizer = wx.FlexGridSizer(2, 1, 0, 0) top_level_sizer.AddGrowableCol(0) top_level_sizer.AddGrowableRow(1) top_level_sizer.SetFlexibleDirection(wx.BOTH) top_level_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.SetSizer(top_level_sizer) # Menu self.menubar = wx.MenuBar(0) self.file_menu = wx.Menu() self.m_menuItem7 = wx.MenuItem(self.file_menu, wx.ID_ANY, u"MyMenuItem", wx.EmptyString, wx.ITEM_NORMAL) self.file_menu.AppendItem(self.m_menuItem7) self.menubar.Append(self.file_menu, u"File") self.m_menu5 = wx.Menu() self.m_menuItem8 = wx.MenuItem(self.m_menu5, wx.ID_ANY, u"MyMenuItem", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem8) self.menubar.Append(self.m_menu5, u"MyMenu") self.m_menu6 = wx.Menu() self.m_menuItem9 = wx.MenuItem(self.m_menu6, wx.ID_ANY, u"MyMenuItem", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu6.AppendItem(self.m_menuItem9) self.menubar.Append(self.m_menu6, u"MyMenu") self.SetMenuBar(self.menubar) # Statusbar self.statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP, wx.ID_ANY) # Toolbar toolbar_sizer = wx.FlexGridSizer(1, 0, 0, 0) self.toolbar = wx.Panel(self, name="toolbar") self.toolbar.SetSizer(toolbar_sizer) self.pause_button = wx.Button(self.toolbar, wx.ID_ANY, u"pause", wx.DefaultPosition, wx.DefaultSize) toolbar_sizer.Add(self.pause_button) self.play_button = wx.Button(self.toolbar, wx.ID_ANY, u"play", wx.DefaultPosition, wx.DefaultSize) toolbar_sizer.Add(self.play_button) self.stop_button = wx.Button(self.toolbar, wx.ID_ANY, u"stop", wx.DefaultPosition, wx.DefaultSize) toolbar_sizer.Add(self.stop_button) top_level_sizer.Add(self.toolbar, 0, wx.EXPAND | wx.ALL, 5) # Content Panel (consisting of a few panels all managed by an auimanager) content_sizer = wx.BoxSizer(wx.VERTICAL) self.content_panel = wx.Panel(self, name="content panel") self.content_panel.SetSizer(content_sizer) top_level_sizer.Add(self.content_panel, 0, wx.EXPAND | wx.ALL, 5) self.mgr = aui.AuiManager( self.content_panel, agwFlags=aui.AUI_MGR_DEFAULT | aui.AUI_MGR_AUTONB_NO_CAPTION | aui.AUI_MGR_WHIDBEY_DOCKING_GUIDES | aui.AUI_MGR_VENETIAN_BLINDS_HINT | aui.AUI_MGR_HINT_FADE) self.mgr.SetAutoNotebookStyle(aui.AUI_NB_TOP | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_CLOSE_BUTTON) # Game Panel self.game_panel = PandaViewport("game", self.content_panel) self.game_panel.SetMinSize(wx.Size(200, 200)) content_sizer.Add(self.game_panel, 1, wx.EXPAND) # Editor Pane self.editor_panel = PandaViewport("editor", self.content_panel) self.editor_panel.SetMinSize(wx.Size(200, 200)) content_sizer.Add(self.editor_panel, 1, wx.EXPAND) # Resources Pane resources_panel_sizer = wx.BoxSizer(wx.VERTICAL) self.resources_panel = wx.Panel(self.content_panel, name="resources_panel") self.resources_panel.SetMinSize(wx.Size(200, 200)) self.resources_panel.SetSizer(resources_panel_sizer) self.resources_dir = wx.TreeCtrl(self.resources_panel, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT) resources_root = self.resources_dir.AddRoot("resources") items = ["test1", "test2", "test3"] for item in items: self.resources_dir.AppendItem(resources_root, item) resources_panel_sizer.Add(self.resources_dir, 1, wx.EXPAND | wx.ALL, 5) content_sizer.Add(self.resources_panel, 1, wx.EXPAND) # Project Panel project_panel_sizer = wx.BoxSizer(wx.VERTICAL) self.project_panel = wx.Panel(self.content_panel, name="project panel") self.project_panel.SetMinSize(wx.Size(200, 200)) self.project_panel.SetSizer(project_panel_sizer) self.project_tree = wx.TreeCtrl(self.project_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT) root = self.project_tree.AddRoot("render") self.project_tree.AppendItem(root, "item1") self.project_tree.AppendItem(root, "item2") project_panel_sizer.Add(self.project_tree, 1, wx.EXPAND) content_sizer.Add(self.project_panel, 1, wx.EXPAND) # Inspector Panel self.inspector_panel = InspectorPanel(self.content_panel) content_sizer.Add(self.inspector_panel, 1, wx.EXPAND) # Add all panes to the manager self.mgr.AddPane( self.resources_panel, aui.AuiPaneInfo().Left().Caption("Resources").Layer(2).MinSize( self.resources_panel.GetMinSize())) self.mgr.AddPane( self.project_panel, aui.AuiPaneInfo().Left().Caption("Project").Layer(2).MinSize( self.project_panel.GetMinSize())) self.mgr.AddPane( self.inspector_panel, aui.AuiPaneInfo().Right().Caption("Inspector").Layer(1).MinSize( self.inspector_panel.GetMinSize())) self.mgr.AddPane( self.game_panel, aui.AuiPaneInfo().Center().Caption("Game").Layer(0).MinSize( self.game_panel.GetMinSize()).MaximizeButton()) self.mgr.AddPane( self.editor_panel, aui.AuiPaneInfo().Bottom().Caption("Editor").Layer(0).MinSize( self.editor_panel.GetMinSize()).MaximizeButton()) self.mgr.Update()
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Sorteo", pos=wx.DefaultPosition, size=wx.Size(800, 600), style=wx.CAPTION | wx.CLOSE_BOX | wx.DEFAULT_FRAME_STYLE | wx.MAXIMIZE | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.SetSizeHintsSz(wx.Size(-1, -1), wx.Size(-1, -1)) self.m_menubar1 = wx.MenuBar(0) self.menu1 = wx.Menu() self.nenu_item_password = wx.MenuItem(self.menu1, wx.ID_ANY, u"Cambio Contraseña", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.nenu_item_password) self.menu_item_puerto = wx.MenuItem(self.menu1, wx.ID_ANY, u"Puerto Dispositivo", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.menu_item_puerto) self.menu_item = wx.MenuItem(self.menu1, wx.ID_ANY, u"Salir", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.menu_item) self.m_menubar1.Append(self.menu1, u"Aplicación") self.menu2 = wx.Menu() self.menuItem2 = wx.MenuItem(self.menu2, wx.ID_ANY, u"Registro de Semanas", wx.EmptyString, wx.ITEM_NORMAL) self.menu2.AppendItem(self.menuItem2) self.m_menubar1.Append(self.menu2, u"Premios") self.menu3 = wx.Menu() self.menuItem3 = wx.MenuItem(self.menu3, wx.ID_ANY, u"Pulsaciones del Día", wx.EmptyString, wx.ITEM_NORMAL) self.menu3.AppendItem(self.menuItem3) self.menuItem4 = wx.MenuItem(self.menu3, wx.ID_ANY, u"Registro Total de Pulsaciones", wx.EmptyString, wx.ITEM_NORMAL) self.menu3.AppendItem(self.menuItem4) self.m_menubar1.Append(self.menu3, u"Registro de Pulsaciones") self.menu4 = wx.Menu() self.menu_item5 = wx.MenuItem(self.menu4, wx.ID_ANY, u"Acerca de", wx.EmptyString, wx.ITEM_NORMAL) self.menu4.AppendItem(self.menu_item5) self.m_menubar1.Append(self.menu4, u"Ayuda") self.SetMenuBar(self.m_menubar1) self.Centre(wx.HORIZONTAL) dlg = wx.PasswordEntryDialog(self, u"Ingrese contraseña", u"Semaforo") if (dlg.ShowModal() == wx.ID_OK): password = str(hash(dlg.GetValue())) p = Parametros.query.first() if (str(p.password) != password): self.Destroy() dlg.Destroy() else: self.Destroy() dlg.Destroy() # Connect Events self.Bind(wx.EVT_MENU, self.menu_itemOnMenuSelection, id=self.menu_item.GetId()) self.Bind(wx.EVT_MENU, self.menuItem2OnMenuSelection, id=self.menuItem2.GetId()) self.Bind(wx.EVT_MENU, self.menu3OnMenuSelection, id=self.menuItem3.GetId()) self.Bind(wx.EVT_MENU, self.menu4OnMenuSelection, id=self.menuItem4.GetId()) self.Bind(wx.EVT_MENU, self.nenu_item_passwordOnMenuSelection, id=self.nenu_item_password.GetId()) self.Bind(wx.EVT_MENU, self.menu_item_puertoOnMenuSelection, id=self.menu_item_puerto.GetId()) self.Bind(wx.EVT_MENU, self.menu_item_aboutOnMenuSelection, id=self.menu_item5.GetId())
def __init__(self): wx.Menu.__init__(self) self.ID_TO_TOOL_ITEM = {} self.cdialog = None #------------ Sub menu of the window and level ---------- submenu_wl = wx.Menu() self._gen_event = True #Window and level from DICOM new_id = self.id_wl_first = wx.NewId() wl_item = wx.MenuItem(submenu_wl, new_id,\ _('Default'), kind=wx.ITEM_RADIO) submenu_wl.Append(wl_item) self.ID_TO_TOOL_ITEM[new_id] = wl_item #Case the user change window and level new_id = self.other_wl_id = wx.NewId() wl_item = wx.MenuItem(submenu_wl, new_id,\ _('Manual'), kind=wx.ITEM_RADIO) submenu_wl.Append(wl_item) self.ID_TO_TOOL_ITEM[new_id] = wl_item for name in sorted(const.WINDOW_LEVEL): if not(name == _('Default') or name == _('Manual')): new_id = wx.NewId() wl_item = wx.MenuItem(submenu_wl, new_id,\ name, kind=wx.ITEM_RADIO) submenu_wl.Append(wl_item) self.ID_TO_TOOL_ITEM[new_id] = wl_item #----------- Sub menu of the save and load options --------- #submenu_wl.AppendSeparator() #options = [_("Save current values"), # _("Save current values as..."),_("Load values")] #for name in options: # new_id = wx.NewId() # wl_item = wx.MenuItem(submenu_wl, new_id,\ # name) # submenu_wl.Append(wl_item) # self.ID_TO_TOOL_ITEM[new_id] = wl_item #------------ Sub menu of the pseudo colors ---------------- if sys.platform.startswith('linux'): mkind = wx.ITEM_CHECK else: mkind = wx.ITEM_RADIO self.pseudo_color_items = {} submenu_pseudo_colours = wx.Menu() self.pseudo_color_items = {} new_id = self.id_pseudo_first = wx.NewId() color_item = wx.MenuItem(submenu_pseudo_colours, new_id,\ _("Default "), kind=mkind) submenu_pseudo_colours.Append(color_item) color_item.Check(1) self.ID_TO_TOOL_ITEM[new_id] = color_item self.pseudo_color_items[new_id] = color_item for name in sorted(const.SLICE_COLOR_TABLE): if not(name == _("Default ")): new_id = wx.NewId() color_item = wx.MenuItem(submenu_wl, new_id,\ name, kind=mkind) submenu_pseudo_colours.Append(color_item) self.ID_TO_TOOL_ITEM[new_id] = color_item self.pseudo_color_items[new_id] = color_item self.plist_presets = presets.get_wwwl_presets() for name in sorted(self.plist_presets): new_id = wx.NewId() color_item = wx.MenuItem(submenu_wl, new_id, name, kind=mkind) submenu_pseudo_colours.Append(color_item) self.ID_TO_TOOL_ITEM[new_id] = color_item self.pseudo_color_items[new_id] = color_item new_id = wx.NewId() color_item = wx.MenuItem(submenu_wl, new_id, _('Custom'), kind=mkind) submenu_pseudo_colours.Append(color_item) self.ID_TO_TOOL_ITEM[new_id] = color_item self.pseudo_color_items[new_id] = color_item # --------------- Sub menu of the projection type --------------------- self.projection_items = {} submenu_projection = wx.Menu() for name in PROJECTIONS_ID: new_id = wx.NewId() projection_item = wx.MenuItem(submenu_projection, new_id, name, kind=wx.ITEM_RADIO) submenu_projection.Append(projection_item) self.ID_TO_TOOL_ITEM[new_id] = projection_item self.projection_items[PROJECTIONS_ID[name]] = projection_item flag_tiling = False #------------ Sub menu of the image tiling --------------- submenu_image_tiling = wx.Menu() for name in sorted(const.IMAGE_TILING): new_id = wx.NewId() image_tiling_item = wx.MenuItem(submenu_image_tiling, new_id,\ name, kind=wx.ITEM_RADIO) submenu_image_tiling.Append(image_tiling_item) self.ID_TO_TOOL_ITEM[new_id] = image_tiling_item #Save first id item if not(flag_tiling): self.id_tiling_first = new_id flag_tiling = True # Add sub itens in the menu self.Append(-1, _("Window width and level"), submenu_wl) self.Append(-1, _("Pseudo color"), submenu_pseudo_colours) self.Append(-1, _("Projection type"), submenu_projection) ###self.Append(-1, _("Image Tiling"), submenu_image_tiling) # It doesn't work in Linux self.Bind(wx.EVT_MENU, self.OnPopup) # In Linux the bind must be putted in the submenu if sys.platform.startswith('linux') or sys.platform == 'darwin': submenu_wl.Bind(wx.EVT_MENU, self.OnPopup) submenu_pseudo_colours.Bind(wx.EVT_MENU, self.OnPopup) submenu_image_tiling.Bind(wx.EVT_MENU, self.OnPopup) submenu_projection.Bind(wx.EVT_MENU, self.OnPopup) self.__bind_events()