def __init__(self, fileName, downLoadFileServerList): """初始方法""" #保存成临时变量 self.fileName = fileName self.downLoadFileServerList = downLoadFileServerList ActionDialog.__init__(self, u"文件下载") StaticText(self.actionPanel, -1, u"您确认要对选择的服务器进行下载文件的操作吗?", (80, 80)) StaticText(self.actionPanel, -1, u"请输入保存路径:", (80, 120)) self.savePath = wx.TextCtrl(self.actionPanel, -1, "", (80, 140), size=(250, 20)) #操作中提示 self.actiontext = StaticText(self.actionPanel, -1, u"正在操作,请稍等...", (160, 250)) self.actiontext.Show(False) self.ok = wx.Button(self.actionPanel, -1, u"确 定", (100, 200)) self.ok.SetForegroundColour("#006699") self.cancel = wx.Button(self.actionPanel, -1, u"取 消", (230, 200)) self.cancel.SetForegroundColour("#006699") #确定、取消事件 self.ok.Bind(wx.EVT_LEFT_DOWN, self.OnDisplayInfo) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOk) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel)
def __init__(self, parent, updateSelfServerList): """初始方法 parent为父对象""" self.parent = parent self.updateSelfServerList = updateSelfServerList ''' self.parent.SysMessaegText.WriteText 使用父对象的消息框输出消息 ''' ActionDialog.__init__(self, u"自更新") StaticText(self.actionPanel, -1, u"您确认要对选择的服务器进行自更新操作吗?", (80, 80)) #操作中提示 self.actiontext = StaticText(self.actionPanel, -1, u"正在操作,请稍等...", (160, 250)) self.actiontext.Show(False) self.ok = wx.Button(self.actionPanel, -1, u"确 定", (100, 200)) self.ok.SetForegroundColour("#006699") self.cancel = wx.Button(self.actionPanel, -1, u"取 消", (230, 200)) self.cancel.SetForegroundColour("#006699") #确定、取消事件 self.ok.Bind(wx.EVT_LEFT_DOWN, self.OnDisplayInfo) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOk) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel)
def __init__(self, parent, ExecCommandServerList): """初始方法 parent为父对象""" self.parent = parent self.ExecCommandServerList = ExecCommandServerList ''' self.parent.SysMessaegText.WriteText 使用父对象的消息框输出消息 ''' ActionDialog.__init__(self, u"执行命令") StaticText(self.actionPanel, -1, u"您确认要发送该命令吗?", (80, 80)) StaticText(self.actionPanel, -1, u"请输入命令:", (80, 120)) self.commandstr = wx.TextCtrl(self.actionPanel, -1, "", (80, 140), size=(250, 20)) #操作中提示 self.actiontext = StaticText(self.actionPanel, -1, u"正在操作,请稍等...", (160, 250)) self.actiontext.Show(False) self.ok = wx.Button(self.actionPanel, -1, u"确 定", (100, 200)) self.ok.SetForegroundColour("#006699") self.cancel = wx.Button(self.actionPanel, -1, u"取 消", (230, 200)) self.cancel.SetForegroundColour("#006699") #确定、取消事件 self.ok.Bind(wx.EVT_LEFT_DOWN, self.OnDisplayInfo) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOk) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel)
def __init__(self, parent): wx.Panel.__init__(self, parent, size=(1,1)) # self.SetBackgroundColour("Gray") # self.SetBackgroundColour("sky blue") StaticText(self, -1, "中文标签控件".decode('utf-8').encode('gb2312'), (120, 70)) #.SetBackgroundColour('Orange') StaticText(self, -1, "this is a label in English\nthis is a label in English12", (120, 100)) os.system('ls') #os system self.cmdLabel = wx.TextCtrl(self, -1, "echo 'please input os cmd'", (0, 0),(560,-1)) self.cmdBtn = wx.Button(self, -1, "Execute", (0, 30), (60, 30)) self.Bind(wx.EVT_BUTTON, self.onCmdBtn, self.cmdBtn)
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) ##self.SetBackgroundColour("sky blue") StaticText(self, -1, "This is an example of static text", (20, 10)) StaticText(self, -1, "using the wx.StaticText Control.", (20, 30)) StaticText(self, -1, "Is this yellow?", (20, 70), (120, -1)).SetBackgroundColour('Yellow') StaticText(self, -1, "align center", (160, 70), (120, -1), wx.ALIGN_CENTER).SetBackgroundColour('Yellow') StaticText(self, -1, "align right", (300, 70), (120, -1), wx.ALIGN_RIGHT).SetBackgroundColour('Yellow') str = "This is a different font." text = StaticText(self, -1, str, (20, 120)) font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) StaticText( self, -1, "Multi-line wx.StaticText\nline 2\nline 3\n\nafter empty line", (20, 170)) StaticText( self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220, 170), style=wx.ALIGN_RIGHT)
def UpdateText(self): text = StaticText(self, -1, self.sent, (20, 430)) text.SetBackgroundColour('White') font = wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL) text.SetFont(font) return(0)
def MakeToolBar(self): TBFLAGS = (wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) tb = self.CreateToolBar(TBFLAGS) tsize = (24, 24) catagory_new_bmp = images.catagory_new.GetBitmap() goods_new_bmp = images.goods_new.GetBitmap() tb.SetToolBitmapSize(tsize) tb.AddTool(10, "新增类别", catagory_new_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "新增类别", "增加物品类别,用于物品归类,便于物品管理'", None) tb.AddTool(20, "新增物品", goods_new_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "新增物品", "添加新的物品", None) self.Bind(wx.EVT_TOOL, self.OnAddCatagory, id=10) self.Bind(wx.EVT_TOOL, self.OnAddGoods, id=20) tb.AddStretchableSpace() login_msg = '您好,{},欢迎使用系统! '.format( userservice.get_current_user().get('username')) login_info = wx.StaticText(tb, wx.ID_ANY, login_msg) tb.AddControl(login_info) tb.AddSeparator() bmp = StaticBitmap(tb, -1, images.setting.GetBitmap()) tb.AddControl(bmp) modifypass_lb = StaticText(tb, -1, "修改密码") tb.AddControl(modifypass_lb) modifypass_lb.Bind(wx.EVT_MOUSE_EVENTS, self.OnModifyPassword) tb.Realize()
def __init__(self, parent, wxId, useHtmlFormatting=True, initialText=''): """Constructor. @param parent Parent wxWidget ID. @param wxId ID of the formatted text widget. @param useHtmlFormatting Use a HTML window widget. @param initialText Initial contents. """ self.useHtml = useHtmlFormatting if self.useHtml: base.Widget.__init__(self, MyHtmlWindow(parent, wxId)) else: if host.isMac(): # It appears wxWidgets fancy text is broken on the Mac. useFancy = True #False else: useFancy = True if useFancy: text = initialText.replace('<b>', '<font weight="bold">') text = text.replace('</b>', '</font>') text = text.replace('<i>', '<font style="italic">') text = text.replace('</i>', '</font>') text = text.replace('<tt>', '<font family="fixed">') text = text.replace('</tt>', '</font>') text = '<font family="swiss" size="%s">' \ % st.getSystemString('style-normal-size') + text + '</font>' # fancytext doesn't support non-ascii chars? text = text.replace('ä', 'a') text = text.replace('ö', 'o') text = text.replace('ü', 'u') text = text.replace('å', 'a') text = text.replace('Ä', 'A') text = text.replace('Ö', 'O') text = text.replace('Ü', 'U') text = text.replace('Å', 'A') else: text = initialText.replace('<b>', '') text = text.replace('</b>', '') text = text.replace('<i>', '') text = text.replace('</i>', '') text = text.replace('<tt>', '') text = text.replace('</tt>', '') # Break it up if too long lines detected. brokenText = breakLongLines(text, 70) if useFancy: base.Widget.__init__(self, fancy.StaticFancyText( parent, wxId, uniConv(brokenText))) else: base.Widget.__init__(self, StaticText(parent, wxId, uniConv(brokenText))) self.resizeToBestSize()
def __init__(self): wx.Dialog.__init__(self, parent=None, id=-1,title=u"OManager服务器管理 ",style=wx.STAY_ON_TOP) self.Center() sizer = wx.GridBagSizer(hgap=5, vgap=10) self.SetBackgroundColour("#ffffff") self.SetIcon(wx.Icon(sys.path[0]+'/img/Loading.ico',wx.BITMAP_TYPE_ICO)) bmp = wx.Image(sys.path[0]+'/img/title.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.logo = wx.StaticBitmap(self, -1, bmp, size=(320, bmp.GetHeight())) sizer.Add(self.logo, pos=(0, 0), span=(1,6), flag=wx.EXPAND) #Loging text self.logintext=StaticText(self, -1, u"正在验证,请稍等...", (70, 210)) self.logintext.Show(False) # Label sizer.Add(wx.StaticText(self, -1, u"用户名: "), pos=(1, 1), flag=wx.ALIGN_RIGHT) sizer.Add(wx.StaticText(self, -1, u"密 码: "), pos=(2, 1), flag=wx.ALIGN_RIGHT) sizer.Add(wx.StaticText(self, -1, u"私 钥: "), pos=(3, 1), flag=wx.ALIGN_RIGHT) # Text self.username = wx.TextCtrl(self, -1,"", size=(120, 20)) self.username.SetMaxLength(20) self.password = wx.TextCtrl(self, -1,"", size=(120, 20), style=wx.TE_PASSWORD) self.password.SetMaxLength(20) self.Privatekey = wx.TextCtrl(self, -1,"", size=(160, 20)) self.Privatekey.SetMaxLength(60) sizer.Add(self.username, pos=(1,2), span=(1,1)) sizer.Add(self.password, pos=(2,2), span=(1,1)) sizer.Add(self.Privatekey, pos=(3,2), span=(1,1)) # Button self.Open = wx.Button(self, -1, u"浏览...", (10, 10)) #self.Open.SetForegroundColour("#ffffff") #self.Open.SetBackgroundColour("#154786") self.ok = wx.Button(self, -1, u"登 录", (35, 20)) self.ok.SetForegroundColour("#FF245D") self.cancel = wx.Button(self, -1, u"退 出", (35, 20)) self.cancel.SetForegroundColour("#006699") # bind the evt self.ok.Bind(wx.EVT_LEFT_DOWN,self.OnDisplayInfo) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOK) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel) #self.logo.Bind(wx.EVT_LEFT_DOWN, self.OnCancel) self.Bind(wx.EVT_BUTTON, self.OnOpenbutton,self.Open) sizer.Add(self.ok, pos=(4,1),flag=wx.EXPAND) sizer.Add(self.cancel, pos=(4,2)) sizer.Add(self.Open, pos=(3,3)) sizer.Add((4, 2), (6, 2)) #sizer.SetEmptyCellSize((10, 40)) sizer.AddGrowableCol(3) sizer.AddGrowableRow(3) self.SetSizer(sizer) self.Fit()
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15)) bmp = images.Test2.GetBitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight())) bmp = images.Robin.GetBitmap() StaticBitmap(self, -1, bmp, (80, 150)) StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175))
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") StaticText(self, -1, "This is an example of static text", (20, 10)) StaticText(self, -1, "using the wx.StaticText Control.", (20, 30)) StaticText(self, -1, "align left(default)", pos=(20, 70), size=(120, -1)).SetBackgroundColour('Yellow') StaticText(self, -1, "align center", pos=(160, 70), size=(120, -1), style=wx.ALIGN_CENTER).SetBackgroundColour('#FF8000') StaticText(self, -1, "align right", pos=(300, 70), size=(120, -1), style=wx.ALIGN_RIGHT).SetBackgroundColour(wx.RED) str = "This is a different font." text = StaticText(self, -1, str, pos=(20, 120)) font = wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) text.SetFont(font) StaticText(self, -1, ("Multi-line wx.StaticText" "\n" "line 2" "\n" "line 3" "\n" "\n" "after empty line"), (20, 170)) StaticText(self, -1, ("Align right multi-line" "\n" "line 2" "\n" "line 3" "\n" "\n" "after empty line"), (220, 170), style=wx.ALIGN_RIGHT)
def __init__(self, parent): """初始方法 parent为父对象""" self.parent = parent ''' self.parent.SysMessaegText.WriteText 使用父对象的消息框输出消息 ''' ActionDialog.__init__(self, u"文件上传") StaticText(self.actionPanel, -1, u"您确认要对选择的文件进行上传吗?", (80, 80)) StaticText(self.actionPanel, -1, u"请选择文件:", (80, 120)) self.filePath = wx.TextCtrl(self.actionPanel, -1, "", (80, 140), size=(250, 20)) self.Open = wx.Button(self.actionPanel, -1, u"浏览...", (350, 140), size=(60, 20)) self.Open.SetForegroundColour("#ffffff") self.Open.SetBackgroundColour("#154786") self.Bind(wx.EVT_BUTTON, self.OnOpenbutton, self.Open) #操作中提示 self.actiontext = StaticText(self.actionPanel, -1, u"正在操作,请稍等...", (160, 250)) self.actiontext.Show(False) self.ok = wx.Button(self.actionPanel, -1, u"确 定", (100, 200)) self.ok.SetForegroundColour("#006699") self.cancel = wx.Button(self.actionPanel, -1, u"取 消", (230, 200)) self.cancel.SetForegroundColour("#006699") #确定、取消事件 self.ok.Bind(wx.EVT_LEFT_DOWN, self.OnDisplayInfo) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOk) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel)
def __init__(self, parent, size=(200, -1), color=None): wx.Panel.__init__(self, parent, size=size) self.SetBackgroundColour(color) self.SetMinSize((200, -1)) # Create a test label. self.label = StaticText(self, wx.ID_ANY, "view annotation area", (20, 10)) font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) self.label.SetFont(font) # Add the label to the sizer. sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.label, 1, wx.EXPAND | wx.ALL, border=0) self.SetSizer(sizer)
def __init__(self, name, pref_item, size, parent=None): ''' The constructor. Parameters ---------- name : String The name of the field. It is used as the field label. pref_item : :class:`~psysmon.core.preferences.PrefItem` The key of the base option edited by this field. size : tuple (width, height) The size of the field. parent : The parent wxPyton window of this field. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field spincontrol. self.controlElement = FS.FloatSpin(parent=self, id=wx.ID_ANY, min_val=pref_item.limit[0], max_val=pref_item.limit[1], increment=pref_item.increment, digits=pref_item.digits, agwStyle=FS.FS_LEFT) self.controlElement.SetFormat(pref_item.spin_format) # Add the elements to the field sizer. self.addLabel(self.labelElement) self.addControl(self.controlElement) # Set the value of the control element. self.setControlElementValue() # Bind the events. self.Bind(FS.EVT_FLOATSPIN, self.onValueChange, self.controlElement)
def __init__(self, name, pref_item, size, parent=None): ''' The constructor. Parameters ---------- name : String The name of the field. It is used as the field label. pref_item : :class:`~psysmon.core.preferences.PrefItem` The key of the base option edited by this field. size : tuple (width, height) The size of the field. parent : The parent wxPyton window of this field. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field text control. if pref_item.tool_tip is None: pref_item.tool_tip = 'Type filename or click browse to choose file.' self.controlElement = filebrowse.FileBrowseButton( self, wx.ID_ANY, labelWidth=0, labelText='', fileMask=pref_item.filemask, changeCallback=self.onValueChange, toolTip=pref_item.tool_tip) # Add the gui elements to the field. self.addLabel(self.labelElement) self.addControl(self.controlElement) # Set the value of the control element. self.setControlElementValue()
def __init__(self, parent, msg, bgColour=None, fgColour=None): wx.Frame.__init__(self, parent, style=wx.BORDER_SIMPLE|wx.FRAME_TOOL_WINDOW|wx.STAY_ON_TOP) bgColour = bgColour if bgColour is not None else wx.Colour(253, 255, 225) fgColour = fgColour if fgColour is not None else wx.BLACK panel = wx.Panel(self) text = StaticText(panel, -1, msg) for win in [panel, text]: win.SetCursor(wx.HOURGLASS_CURSOR) win.SetBackgroundColour(bgColour) win.SetForegroundColour(fgColour) size = text.GetBestSize() self.SetClientSize((size.width + 60, size.height + 40)) panel.SetSize(self.GetClientSize()) text.Center() self.Center()
def __init__(self, name, pref_item, size, parent=None): ''' The constructor. Parameters ---------- name : String The name of the field. It is used as the field label. pref_item : :class:`~psysmon.core.preferences.PrefItem` The key of the base option edited by this field. size : tuple (width, height) The size of the field. parent : The parent wxPyton window of this field. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field text control. self.controlElement = wx.ListBox(self, wx.ID_ANY, choices=pref_item.limit, style=wx.LB_MULTIPLE) self.addLabel(self.labelElement) self.addControl(self.controlElement) # Set the value of the control element. self.setControlElementValue() # Bind the events. self.Bind(wx.EVT_LISTBOX, self.onValueChange, self.controlElement)
def __init__(self, name, pref_item, size, parent=None): ''' Initialize the instance. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field text control. self.controlElement = SortableListCtrl( parent=self, id=wx.ID_ANY, style=wx.LC_REPORT | wx.BORDER_NONE #| wx.LC_SINGLE_SEL | wx.LC_SORT_ASCENDING, n_columns=len(pref_item.column_labels)) self.controlElement.itemDataMap = {} for k, cur_label in enumerate(pref_item.column_labels): self.controlElement.InsertColumn(k, cur_label) self.fill_listctrl(data=pref_item.limit) #listmix.ColumnSorterMixin.__init__(self, len(pref_item.column_labels)) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_item_selected, self.controlElement) self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.on_item_deselected, self.controlElement) # Add the gui elements to the field. self.addLabel(self.labelElement) self.addControl(self.controlElement)
def __init__(self, name, pref_item, size, parent=None): ''' The constructor. Parameters ---------- name : String The name of the field. It is used as the field label. pref_item : :class:`~psysmon.core.preferences.PrefItem` The key of the base option edited by this field. size : tuple (width, height) The size of the field. parent : The parent wxPyton window of this field. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field text control. self.controlElement = FileGrid( parent=self, data=self.pref_item.value, column_labels=self.pref_item.column_labels) # Add the gui elements to the field. self.addLabel(self.labelElement) self.addControl(self.controlElement)
def __init__(self, name, pref_item, size, parent = None): ''' Initialize the instance. ''' wx.Panel.__init__(self, parent = parent, size = size, id = wx.ID_ANY) self.name = name self.pref_item = pref_item self.size = size self.label = name + ":" self.labelElement = None self.controlElement = None self.sizer = wx.GridBagSizer(5, 5) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_LEFT) self.sizer.Add(self.labelElement, pos = (0,0), flag = wx.EXPAND|wx.ALL, border = 0) self.controlElement = PStackEditPanel(parent = self, size = (-1, 300)) self.sizer.Add(self.controlElement, pos = (1,0), flag = wx.EXPAND|wx.ALL, border = 0) self.sizer.AddGrowableCol(0) self.sizer.AddGrowableRow(1) self.SetSizer(self.sizer)
def __init__(self, name, pref_item, size, parent=None): ''' ''' wx.Panel.__init__(self, parent=parent, size=size, id=wx.ID_ANY) self.name = name self.pref_item = pref_item self.size = size self.label = name + ":" self.labelElement = None self.controlElement = None self.sizer = wx.GridBagSizer(5, 5) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_LEFT) self.sizer.Add(self.labelElement, pos=(0, 0), flag=wx.EXPAND | wx.ALL, border=0) self.controlElement = EventListCtrl(parent=self, size=(200, 300), style=wx.LC_REPORT | wx.BORDER_NONE | wx.LC_SINGLE_SEL | wx.LC_SORT_ASCENDING) # The columns to show as a list to keep it in the correct order. self.columns = [ 'db_id', 'start_time', 'length', 'public_id', 'description', 'agency_uri', 'author_uri', 'comment' ] # The labels of the columns. self.column_labels = { 'db_id': 'id', 'start_time': 'start time', 'length': 'length', 'public_id': 'public id', 'description': 'description', 'agency_uri': 'agency', 'author_uri': 'author', 'comment': 'comment' } # Methods for derived values. self.get_method = {'length': self.get_length} # Methods for values which should not be converted using the default # str function. self.convert_method = {'start_time': self.convert_to_isoformat} for k, name in enumerate(self.columns): self.controlElement.InsertColumn(k, self.column_labels[name]) self.sizer.Add(self.controlElement, pos=(1, 0), flag=wx.EXPAND | wx.ALL, border=0) self.sizer.AddGrowableCol(0) self.sizer.AddGrowableRow(1) self.SetSizer(self.sizer)
def getDefaultTextField(self, t=""): text = StaticText(self, -1, t) text.SetForegroundColour(wx.WHITE) text.SetBackgroundColour(self.guiUtility.triblerRed) return text
def __init__(self, parent, log): wx.Frame.__init__(self, parent, title="BalloonTip wxPython Demo ;-)") self.statusbar = self.CreateStatusBar(2) self.statusbar.SetStatusWidths([-2, -1]) # statusbar fields statusbar_fields = [("Welcome To WxPython " + wx.VERSION_STRING), ("BalloonTip Demo")] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.SetIcon(images.Mondrian.GetIcon()) self.SetMenuBar(self.CreateMenuBar()) panel = wx.Panel(self, -1) mainsizer = wx.FlexGridSizer(3, 4, hgap=2, vgap=2) # Add A Button button = wx.Button(panel, -1, "Press Me!") # Add A TextCtrl textctrl = wx.TextCtrl(panel, -1, "I Am A TextCtrl") # Add A CheckBox checkbox = wx.CheckBox(panel, -1, "3-State Checkbox", style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER) samplelist = [ 'One', 'Two', 'Three', 'Four', 'Kick', 'The', 'Demo', 'Out', 'The', 'Door', ';-)' ] # Add A Choice choice = wx.Choice(panel, -1, choices=samplelist) # Add A Gauge gauge = wx.Gauge(panel, -1, 50, style=wx.GA_SMOOTH) # Add A ListBox listbox = wx.ListBox(panel, -1, choices=samplelist, style=wx.LB_SINGLE) # Add A TreeCtrl isz = (16, 16) treecontrol = wx.TreeCtrl(panel, -1) il = wx.ImageList(isz[0], isz[1]) fldridx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) fldropenidx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) fileidx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) treecontrol.SetImageList(il) self.il = il root = treecontrol.AddRoot("ROOT") treecontrol.SetItemData(root, None) treecontrol.SetItemImage(root, fldridx, wx.TreeItemIcon_Normal) treecontrol.SetItemImage(root, fldropenidx, wx.TreeItemIcon_Expanded) for ii in range(11): child = treecontrol.AppendItem(root, samplelist[ii]) treecontrol.SetItemData(child, None) treecontrol.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal) treecontrol.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Selected) # Add A Slider slider = wx.Slider(panel, -1, 25, 1, 100, style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS) # | wx.SL_LABELS) slider.SetTickFreq(5) # Add Another TextCtrl textctrl2 = wx.TextCtrl(panel, -1, "Another TextCtrl") # Add A GenStaticText statictext = StaticText(panel, -1, "Hello World!") statictext.SetFont( wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False)) bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR, (16, 16)) # Add A GenBitmapButton bitmapbutton = BitmapButton(panel, -1, bmp) button2 = wx.Button(panel, -1, "Disable BalloonTip") tbicon = TaskBarIcon() tbicon.SetIcon(images.Mondrian.GetIcon()) controls = list(panel.GetChildren()) controls.append(tbicon) self.tbicon = tbicon # Add The Controls To The Main FlexGridSizer mainsizer.Add(button, 0, wx.EXPAND | wx.ALL, 10) mainsizer.Add(textctrl, 0, wx.EXPAND | wx.ALL, 10) mainsizer.Add(checkbox, 0, wx.EXPAND | wx.ALL, 10) mainsizer.Add(choice, 0, wx.EXPAND | wx.ALL, 10) mainsizer.Add(gauge, 0, wx.ALL, 10) mainsizer.Add(listbox, 0, wx.EXPAND | wx.ALL, 10) mainsizer.Add(treecontrol, 0, wx.EXPAND, wx.ALL, 10) mainsizer.Add(slider, 0, wx.ALL, 10) mainsizer.Add(textctrl2, 0, wx.ALL, 10) mainsizer.Add(statictext, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 10) mainsizer.Add(bitmapbutton, 0, wx.ALL, 10) mainsizer.Add(button2, 0, wx.ALL, 10) panel.SetSizer(mainsizer) mainsizer.Layout() # Declare The BalloonTip Background Colours bgcolours = [ None, wx.WHITE, wx.GREEN, wx.BLUE, wx.CYAN, wx.RED, None, None, wx.LIGHT_GREY, None, wx.WHITE, None, None ] # Declare The BalloonTip Top-Left Icons icons = [] for ii in range(4): bmp = wx.ArtProvider.GetBitmap(eval(ArtIDs[ii]), wx.ART_TOOLBAR, (16, 16)) icons.append(bmp) icons.extend([None] * 5) for ii in range(4, 9): bmp = wx.ArtProvider.GetBitmap(eval(ArtIDs[ii]), wx.ART_TOOLBAR, (16, 16)) icons.append(bmp) # Declare The BalloonTip Top Titles titles = [ "Button Help", "Texctrl Help", "CheckBox Help", "Choice Help", "Gauge Help", "", "", "Read Me Carefully!", "SpinCtrl Help", "StaticText Help", "BitmapButton Help", "Button Help", "Taskbar Help" ] fontone = wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, True) fonttwo = wx.Font(14, wx.FONTFAMILY_SCRIPT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False) fontthree = wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL, False) fontfour = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, True) # Declare The BalloonTip Top Titles Fonts titlefonts = [ None, None, fontone, None, fonttwo, fontthree, None, None, None, fontfour, fontthree, None, None ] # Declare The BalloonTip Top Titles Colours titlecolours = [ None, None, wx.WHITE, wx.YELLOW, None, wx.WHITE, wx.BLUE, wx.RED, None, None, wx.LIGHT_GREY, None, None ] # Declare The BalloonTip Messages msg1 = "This Is The Default BalloonTip Window\nYou Can Customize It! "\ "Look At The Demo!" msg2 = "You Can Change The Background Colour\n Of The Balloon Window." msg3 = "You Can Also Change The Font And The\nColour For The Title." msg4 = "I Have Nothing Special To Suggest!\n\nWelcome To wxPython " + \ wx.VERSION_STRING + " !" msg5 = "What About If I Don't Want The Icon?\nNo Problem!" msg6 = "I Don't Have The Icon Nor The Title.\n\nDo You Love Me Anyway?" msg7 = "Some Comments On The Window Shape:\n\n- BT_ROUNDED: Creates A "\ "Rounded Rectangle;\n- BT_RECTANGLE: Creates A Rectangle.\n" msg8 = "Some Comments On The BalloonTip Style:\n\n"\ "BT_LEAVE: The BalloonTip Is Destroyed When\nThe Mouse Leaves"\ "The Target Widget;\n\nBT_CLICK: The BalloonTip Is Destroyed When\n"\ "You Click Any Region Of The BalloonTip;\n\nBT_BUTTON: The BalloonTip"\ " Is Destroyed When\nYou Click On The Top-Right Small Button." msg9 = "Some Comments On Delay Time:\n\nBy Default, The Delay Time After Which\n"\ "The BalloonTip Is Destroyed Is Very Long.\nYou Can Change It By Using"\ " The\nSetEndDelay() Method." msg10 = "I Have Nothing Special To Suggest!\n\nRead Me FAST, You Have Only 3 "\ "Seconds!" msg11 = "I Hope You Will Enjoy BalloonTip!\nIf This Is The Case, Please\n"\ "Post Some Comments On wxPython\nMailing List!" msg12 = "This Button Enable/Disable Globally\nThe BalloonTip On Your Application." msg13 = "This Is A BalloonTip For The\nTaskBar Icon Of Your Application.\n"\ "All The Styles For BalloonTip Work." messages = [ msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9, msg10, msg11, msg12, msg13 ] # Declare The BalloonTip Tip Messages Colours messagecolours = [ None, None, None, wx.WHITE, wx.BLUE, None, wx.BLUE, None, None, wx.RED, wx.GREEN, wx.BLUE, None ] fontone = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, True) fonttwo = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL, False) fontthree = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, True) # Declare The BalloonTip Tip Messages Fonts messagefonts = [ None, None, None, fontone, None, None, fonttwo, None, fontthree, None, None, None, None ] # Declare The BalloonTip Frame Shapes windowshapes = [ BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_ROUNDED, BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_RECTANGLE ] # Declare The BalloonTip Destruction Style tipstyles = [ BT.BT_LEAVE, BT.BT_CLICK, BT.BT_BUTTON, BT.BT_LEAVE, BT.BT_CLICK, BT.BT_LEAVE, BT.BT_CLICK, BT.BT_BUTTON, BT.BT_BUTTON, BT.BT_CLICK, BT.BT_LEAVE, BT.BT_LEAVE, BT.BT_BUTTON ] # Set The Targets/Styles For The BalloonTip for ii, widget in enumerate(controls): tipballoon = BT.BalloonTip(topicon=icons[ii], toptitle=titles[ii], message=messages[ii], shape=windowshapes[ii], tipstyle=tipstyles[ii]) # Set The Target tipballoon.SetTarget(widget) # Set The Balloon Colour tipballoon.SetBalloonColour(bgcolours[ii]) # Set The Font For The Top Title tipballoon.SetTitleFont(titlefonts[ii]) # Set The Colour For The Top Title tipballoon.SetTitleColour(titlecolours[ii]) # Set The Font For The Tip Message tipballoon.SetMessageFont(messagefonts[ii]) # Set The Colour For The Tip Message tipballoon.SetMessageColour(messagecolours[ii]) # Set The Delay After Which The BalloonTip Is Created tipballoon.SetStartDelay(1000) if ii == 9: # Set The Delay After Which The BalloonTip Is Destroyed tipballoon.SetEndDelay(3000) # Store The Last BalloonTip Reference To Enable/Disable Globall The # BalloonTip. You Can Store Any Of Them, Not Necessarily The Last One. self.lasttip = tipballoon self.gauge = gauge self.count = 0 button2.Bind(wx.EVT_BUTTON, self.OnActivateBalloon) self.Bind(wx.EVT_IDLE, self.IdleHandler) frameSizer = wx.BoxSizer(wx.VERTICAL) frameSizer.Add(panel, 1, wx.EXPAND) self.SetSizer(frameSizer) frameSizer.Layout() self.Fit() self.CenterOnParent()
def __init__(self, parent, frame=None): wx.Panel.__init__( self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE ) self.parent = parent self.frame = frame self.pid = 0x1297 #iPhone self.vid = 0x05ac #iPhone self.dev = 0 x = 0 self.bmRequestTypeList = [] self.bRequestList = [] self.wValueListmsb = [] self.wValueListlsb = [] self.wIndexListmsb = [] self.wIndexListlsb = [] self.wLengthListmsb = [] self.wLengthListlsb = [] self.bmRequestType = 0 self.bRequest = 0 self.wValue = 0 self.wIndex = 0 self.wLength = 0 self.bmRequestTypeE = 255 self.bRequestE = 255 self.wValueE = 65535 self.wIndexE = 65535 self.bmRequestTypefuzz = False self.bRequestfuzz = False self.wValuefuzz = False self.wIndexfuzz = False self.bmRequestTypeList = ["%02x" % i for i in range (256)] self.bRequestList = self.bmRequestTypeList self.wValueListmsb = self.bmRequestTypeList self.wValueListlsb = self.bmRequestTypeList self.wIndexListmsb = self.bmRequestTypeList self.wIndexListlsb = self.bmRequestTypeList self.wLengthListmsb = self.bmRequestTypeList self.wLengthListlsb = self.bmRequestTypeList self.fuzzing = 0 self.SetBackgroundColour("White") self.Refresh() # create IDs self.ID_Select_Device = wx.NewId() self.ID_About = wx.NewId() # create menu self.mb = wx.MenuBar() device_menu = wx.Menu() device_menu.Append(self.ID_Select_Device, "&Select USB device") device_menu.Append(self.ID_About, "&About") device_menu.AppendSeparator() device_menu.Append(wx.ID_EXIT, "Exit") self.mb.Append(device_menu, "File") self.parent.SetMenuBar(self.mb) # Create status bar self.statusbar = self.parent.CreateStatusBar(3, wx.ST_SIZEGRIP) self.statusbar.SetStatusWidths([-1,-2, -2]) self.statusbar.SetStatusText("", 0) self.statusbar.SetStatusText("Connection Status: Not connected", 1) self.statusbar.SetStatusText("Fuzzing Status: Not fuzzing", 2) # Background images image_file = 'images/frisbee_logo.png' image = wx.Bitmap(image_file) image_size = image.GetSize() bm = wx.StaticBitmap(self, wx.ID_ANY, image, size=image_size, pos=(0,3)) image_file = 'images/frisbee_name.png' image = wx.Bitmap(image_file) image_size = image.GetSize() bm = wx.StaticBitmap(self, wx.ID_ANY, image, size=image_size, pos=(195,75)) image_file = 'images/nccgrouplogo.png' image = wx.Bitmap(image_file) image_size = image.GetSize() bm = wx.StaticBitmap(self, wx.ID_ANY, image, size=image_size, pos=(310,10)) # Titles text = wx.StaticText(self, -1, "Start values",pos=(120,130)) text.SetBackgroundColour('White') font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) text = wx.StaticText(self, -1, "Fuzz?",pos=(252,130)) text.SetBackgroundColour('White') font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) text = wx.StaticText(self, -1, "End values",pos=(290,130)) text.SetBackgroundColour('White') font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) # Combo boxes text = wx.StaticText(self, -1, "bmRequestType: ",pos=(10,150)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.cbmRequestType = wx.ComboBox(self, 500, "00", (120, 150), (130, -1), self.bmRequestTypeList, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbmRequestType, self.cbmRequestType) text = wx.StaticText(self, -1, "bRequest: ",pos=(10,180)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.cbRequest = wx.ComboBox(self, 501, "00", (120, 180), (130, -1), self.bRequestList, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbRequest, self.cbRequest) text = wx.StaticText(self, -1, "wValue: ",pos=(10,210)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.cbValue1 = wx.ComboBox(self, 502, "00", (120, 210), (65, -1), self.wValueListmsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbValue1, self.cbValue1) self.cbValue2 = wx.ComboBox(self, 512, "00", (185, 210), (65, -1), self.wValueListlsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbValue2, self.cbValue2) text = wx.StaticText(self, -1, "wIndex: ",pos=(10,240)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.cbIndex1 = wx.ComboBox(self, 503, "00", (120, 240), (65, -1), self.wIndexListmsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbIndex1, self.cbIndex1) self.cbIndex2 = wx.ComboBox(self, 513, "00", (185, 240), (65, -1), self.wIndexListlsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbIndex2, self.cbIndex2) self.cbmRequestTypeE = wx.ComboBox(self, 504, "ff", (290, 150), (130, -1), self.bmRequestTypeList, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbmRequestTypeE, self.cbmRequestTypeE) self.cbRequestE = wx.ComboBox(self, 505, "ff", (290, 180), (130, -1), self.bRequestList, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbRequestE, self.cbRequestE) self.cbValue1E = wx.ComboBox(self, 506, "ff", (290, 210), (65, -1), self.wValueListmsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbValue1E, self.cbValue1E) self.cbValue2E = wx.ComboBox(self, 516, "ff", (355, 210), (65, -1), self.wValueListlsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbValue2E, self.cbValue2E) self.cbIndex1E = wx.ComboBox(self, 507, "ff", (290, 240), (65, -1), self.wIndexListmsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbIndex1E, self.cbIndex1E) self.cbIndex2E = wx.ComboBox(self, 517, "ff", (355, 240), (65, -1), self.wIndexListlsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbIndex2E, self.cbIndex2E) text = wx.StaticText(self, -1, "wLength: ",pos=(10,270)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.cbLength1 = wx.ComboBox(self, 508, "00", (120, 270), (65, -1), self.wLengthListmsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbLength1, self.cbLength1) self.cbLength2 = wx.ComboBox(self, 518, "00", (185, 270), (65, -1), self.wLengthListlsb, wx.CB_DROPDOWN ) self.Bind(wx.EVT_COMBOBOX, self.EvtcbLength2, self.cbLength2) # Checkboxes cb1 = wx.CheckBox(self, -1, "", (260, 150), (20, 20), wx.BORDER) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox1, cb1) cb2 = wx.CheckBox(self, -1, "", (260, 180), (20, 20), wx.BORDER) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox2, cb2) cb3 = wx.CheckBox(self, -1, "", (260, 210), (20, 20), wx.BORDER) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox3, cb3) cb4 = wx.CheckBox(self, -1, "", (260, 240), (20, 20), wx.BORDER) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox4, cb4) # Buttons imgStart = wx.Image('images/play.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap() bmbSingleShot = wx.BitmapButton(self, -1, imgStart, (10, 325), style = wx.NO_BORDER) imgStart = wx.Image('images/play.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap() bmbStart = wx.BitmapButton(self, -1, imgStart, (90, 325), style = wx.NO_BORDER) imgStop = wx.Image('images/stop.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap() bmbStop = wx.BitmapButton(self, -1, imgStop, (140, 325), style = wx.NO_BORDER) txt = wx.StaticText(self, -1, "Progress: ",pos=(220,300)) txt.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) txt.SetFont(font) # Progress gauge self.FuzzProgress = wx.Gauge(self, -1, 256, (220, 325), (200, 30)) # Text output pane text = StaticText(self, -1, "Fuzzer controls:", (82, 300)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) text = StaticText(self, -1, "Single:", (10, 300)) text.SetBackgroundColour('White') font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) text.SetFont(font) # Bind events self.parent.Bind(wx.EVT_MENU, self.SelectDevice, id=self.ID_Select_Device) self.parent.Bind(wx.EVT_MENU, self.About, id=self.ID_About) self.parent.Bind(wx.EVT_MENU, self.CloseMe, id=wx.ID_EXIT) self.Bind(wx.EVT_BUTTON, self.SingleShot, bmbSingleShot) self.Bind(wx.EVT_BUTTON, self.FuzzDevice, bmbStart) self.Bind(wx.EVT_BUTTON, self.StopFuzzing, bmbStop)