示例#1
0
def getStaticTextBuff(parent, id, text, pos, size, bCreate=True):
    """
    Возвращает StaticText из буфера либо создает новый.
    """
    global staticTextBuff
    _uuid = parent._uuid
    bBuff = False

    if _uuid not in staticTextBuff or bCreate:
        statTextCtrl = GenStaticText(parent, -1, text, pos, size)
    else:
        try:
            statTextCtrl = staticTextBuff[_uuid].pop(0)
            statTextCtrl.SetPosition(pos)
            statTextCtrl.SetSize(size)
            statTextCtrl.SetLabel(text)

            font = icFont({})
            statTextCtrl.SetFont(font)
            statTextCtrl.Show(True)
            bBuff = True
        except:
            LogLastError('GIVE FROM BUFF ERROR')
            staticTextBuff = {}
            statTextCtrl = GenStaticText(parent, -1, text, pos, size)

    return bBuff, statTextCtrl
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
class TdViewAnnotationPanel(wx.Panel):
    '''
    The view annotation area.

    This area can be used to plot anotations for the view. This might be 
    some statistic values (e.g. min, max), the axes limits or some 
    other custom info.
    '''
    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)

        #print label.GetAlignment()

    def setLabel(self, text):
        ''' Set the text of the annotation label.
        '''
        self.label.SetLabelText(text)
        self.label.Refresh()
示例#5
0
    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)
示例#6
0
class FrameworkStatusBar(wx.StatusBar):
    """A custom status bar for displaying the application version in the bottom
    right corner."""
    def __init__(self, parent, widths, error_delay):
        wx.StatusBar.__init__(self, parent, -1)
        self.error_delay = error_delay

        self.SetFieldsCount(len(widths))
        self.SetStatusWidths(widths)

        self.field_widths = list(widths)
        self.error_control = GenStaticText(self, -1)
        self.error_control.Hide()
        self.message_expire_time = 0
        self.reposition_controls()

        self.expire_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.expire_timer)
        self.Bind(wx.EVT_SIZE, self.on_size)

        f = self.GetFont()
        self.error_control.SetFont(
            wx.Font(f.GetPointSize(), f.GetFamily(), f.GetStyle(), wx.BOLD,
                    f.GetUnderlined(), f.GetFaceName(), f.GetEncoding()))
        self.error_control.SetForegroundColour((255, 255, 255))
        self.error_control.SetBackgroundColour((211, 72, 54))

    def on_size(self, event):
        self.reposition_controls()

    def on_timer(self, event):
        self.error_control.Hide()

    def reposition_controls(self):
        rect = self.GetFieldRect(0)
        self.error_control.SetRect(rect)

    def show_error(self, text):
        self.error_control.SetLabel(" " + text)
        rect = self.GetFieldRect(0)
        self.error_control.SetRect(rect)
        self.error_control.Show()
        self.expire_timer.Start(self.error_delay * 1000, oneShot=True)
示例#7
0
    def InitUI(self):

        panel = wx.Panel(self)

        vbox = wx.BoxSizer(wx.VERTICAL)
        hbox = wx.BoxSizer(wx.HORIZONTAL)

        st = GenStaticText(panel, label='Go to web site:')
        st.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.BOLD, False, 'Verdana'))
        hbox.Add(st, flag=wx.LEFT, border=20)

        link_wid = Link(panel, label='ZetCode')
        link_wid.SetUrl('http://www.zetcode.com')
        hbox.Add(link_wid, flag=wx.LEFT, border=20)

        vbox.Add(hbox, flag=wx.TOP, border=30)
        panel.SetSizer(vbox)

        self.SetTitle('A Hyperlink')
        self.Centre()
示例#8
0
class StaticTextFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Static Text Example',
                          size=(400, 300))
        self.panel = wx.Panel(self, -1)

        self.one = GST(self.panel, wx.NewId(),
                       "This is an example of static text", (100, 10))

        self.rev = GST(self.panel, wx.NewId(),
                       "Static Text With Reversed Colors", (100, 30))
        self.rev.SetForegroundColour('white')
        self.rev.SetBackgroundColour('black')

        self.center = GST(self.panel, wx.NewId(), "align center", (100, 50),
                          (160, -1), wx.ALIGN_CENTER)
        self.center.SetForegroundColour('white')
        self.center.SetBackgroundColour('black')

        self.right = GST(self.panel, wx.NewId(), "align right", (100, 70),
                         (160, -1), wx.ALIGN_RIGHT)
        self.right.SetForegroundColour('white')
        self.right.SetBackgroundColour('black')

        str = "You can also change the font."
        self.text = GST(self.panel, wx.NewId(), str, (20, 100))
        font = wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)
        self.text.SetFont(font)

        GST(
            self.panel, wx.NewId(), "Your text\ncan be split\n"
            "over multiple lines\n\neven blank ones", (20, 150))
        GST(self.panel,
            wx.NewId(), "Multi-line text\ncan also\n"
            "be right aligned\n\neven with a blank", (220, 150),
            style=wx.ALIGN_RIGHT)
示例#9
0
    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()
示例#10
0
class StatusbarWidget(wx.StatusBar):
    def __init__(self, parent):
        super(StatusbarWidget, self).__init__(parent, style=wx.SB_FLAT)
        self.SetFieldsCount(3)
        self.SetStatusWidths([-6, -1, -1])
        self.size_changed = False

        self._label_info = GenStaticText(self, -1, '')
        self._label_coord = GenStaticText(self, -1, '')
        self._label_simulation = GenStaticText(self, -1, '')

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_IDLE, self.on_idle)

    def set_log_text(self, msg, mode=psi.LOG_INFO):
        self._label_info.SetLabel(msg)

        font = self._label_info.GetFont()

        if mode == psi.LOG_ERROR:
            self._label_info.SetForegroundColour((193, 43, 1))
            font.SetWeight(wx.BOLD)

        else:
            self._label_info.SetForegroundColour((0, 0, 0))
            font.SetWeight(wx.NORMAL)

        self._label_info.SetFont(font)

    def set_coord_text(self, msg):
        self._label_coord.SetLabel(msg)

    def set_simulation_text(self, msg):
        self._label_simulation.SetLabel(msg)
        # self.SetStatusText(msg, 1)

    def on_size(self, event):
        self.reposition()
        self.size_changed = True

    def on_idle(self, event):
        if self.size_changed:
            self.reposition()

    def reposition(self):
        rect = self.GetFieldRect(0)
        self._label_info.SetPosition((rect.x + 3, rect.y + 4))
        self._label_info.SetSize((rect.width - 4, rect.height - 4))

        rect = self.GetFieldRect(1)
        self._label_coord.SetPosition((rect.x + 3, rect.y + 4))
        self._label_coord.SetSize((rect.width - 4, rect.height - 4))

        rect = self.GetFieldRect(2)
        self._label_simulation.SetPosition((rect.x + 3, rect.y + 4))
        self._label_simulation.SetSize((rect.width - 4, rect.height - 4))

        self.size_changed = False

    def SetStatusText(self, *args, **kwargs):
        'ignoring'
        pass
示例#11
0
    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)   
示例#12
0
文件: launch.py 项目: tuksik/evette
def LaunchDialog(localsettings, splashimagepath=False):

    dialog = wx.Dialog(None, -1, "Evette")
    dialog.Bind(wx.EVT_CLOSE, ExitApp)

    iconFile = "icons/evette.ico"
    icon1 = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO)
    dialog.SetIcon(icon1)

    dialogsizer = wx.BoxSizer(wx.VERTICAL)

    panel = wx.Panel(dialog)

    topsizer = wx.BoxSizer(wx.VERTICAL)

    bgsizer = wx.BoxSizer(wx.VERTICAL)

    if splashimagepath == False:

        imagebitmap = wx.Bitmap(miscmethods.GetImagePath())

    else:

        imagebitmap = wx.Bitmap("icons/images/" + splashimagepath)

    randomimage = wx.StaticBitmap(panel, -1, imagebitmap)
    framesize = imagebitmap.GetSize()
    bgsizer.Add(randomimage, 0, wx.ALIGN_CENTER)

    spacer = GenStaticText(panel, -1, "")
    topsizer.Add(spacer, 1, wx.EXPAND)

    horizontalsizer = wx.BoxSizer(wx.HORIZONTAL)

    infosizer = wx.BoxSizer(wx.VERTICAL)

    infosizer.Add(GenStaticText(panel, 1, ""), 1, wx.EXPAND)

    versionnolabel = GenStaticText(panel, -1,
                                   GetLabel("versionlabel", localsettings))
    font = versionnolabel.GetFont()
    font.SetPointSize(font.GetPointSize() - 2)
    versionnolabel.SetFont(font)
    infosizer.Add(versionnolabel, 0, wx.ALIGN_CENTER)

    versionnoentry = GenStaticText(panel, -1,
                                   str(dbupdates.GetCurrentVersion()))
    font = versionnoentry.GetFont()
    font.SetPointSize(font.GetPointSize() + 8)
    font.SetWeight(wx.FONTWEIGHT_BOLD)
    versionnoentry.SetFont(font)
    versionnoentry.SetForegroundColour("blue")
    infosizer.Add(versionnoentry, 0, wx.ALIGN_CENTER)

    infosizer.Add(GenStaticText(panel, 1, ""), 1, wx.EXPAND)

    horizontalsizer.Add(infosizer, 1, wx.ALIGN_BOTTOM)

    horizontalsizer.Add(GenStaticText(panel, -1, ""), 1, wx.EXPAND)

    entrysizer = wx.BoxSizer(wx.VERTICAL)

    userlabel = GenStaticText(panel, -1,
                              GetLabel("usernamelabel", localsettings) + ":")
    font = userlabel.GetFont()
    font.SetPointSize(font.GetPointSize() - 2)
    userlabel.SetFont(font)
    entrysizer.Add(userlabel, 0, wx.ALIGN_LEFT)

    userentry = wx.TextCtrl(panel,
                            -1,
                            localsettings.lastuser,
                            size=(150, -1),
                            style=wx.TE_PROCESS_ENTER)
    userentry.description = "username"
    userentry.Bind(wx.EVT_CHAR, ButtonPressed)
    userentry.SetToolTipString(
        GetLabel("tabbetweenentriestooltip", localsettings))
    userentry.SetFocus()
    entrysizer.Add(userentry, 0, wx.EXPAND)

    passwordlabel = GenStaticText(
        panel, -1,
        GetLabel("passwordlabel", localsettings) + ":")
    passwordlabel.SetFont(font)
    entrysizer.Add(passwordlabel, 0, wx.ALIGN_LEFT)

    passwordentry = wx.TextCtrl(panel,
                                -1,
                                "",
                                style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER)
    passwordentry.description = "password"
    passwordentry.SetFocus()
    passwordentry.Bind(wx.EVT_CHAR, ButtonPressed)
    entrysizer.Add(passwordentry, 0, wx.EXPAND)

    horizontalsizer.Add(entrysizer, 0, wx.ALIGN_BOTTOM)

    topsizer.Add(horizontalsizer, 1, wx.EXPAND)

    panel.SetSizer(topsizer)

    panel.userentry = userentry
    panel.passwordentry = passwordentry
    panel.localsettings = localsettings

    dialogsizer.Add(panel, 1, wx.EXPAND)

    dialog.SetSizer(dialogsizer)

    dialog.panel = panel

    dialog.SetSize(framesize)
    dialog.CenterOnScreen()

    dialog.ShowModal()