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)
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)
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)
class XDialog(wx.Panel): def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.entry_label = GenStaticText(self, wx.ID_ANY, label=" default label ", size=(-1, 30)) # Use the default width (-1) and 30 pixel height # Set the background color to palegoldenrod self.entry_label.SetBackgroundColour('#EEE8AA') self.entry = wx.TextCtrl(self, wx.ID_ANY, '') self.entry.SetBackgroundColour('#EEE8AA') self.entry.SetWindowStyleFlag(wx.TE_PROCESS_ENTER) # Arrange the widgets in a horizontal BoxSizer dlg_sizer = wx.BoxSizer(wx.HORIZONTAL) dlg_sizer.Add(self.entry_label, 1, border=0) dlg_sizer.Add(self.entry, 1, wx.EXPAND, border=0) self.SetSizer(dlg_sizer)
def make_test_items(self, features): self.alpha_title = GenStaticText(self, size=(100, -1), label="Choose Alpha: ", style=wx.ALIGN_RIGHT) self.alpha_title.SetBackgroundColour((210, 210, 210)) self.alpha_choice = wx.ComboBox(self, self.id, choices=[], style=wx.CB_READONLY) self.toggle_Coeffs([False, False]) self.gensizer.Add(self.alpha_title, 1) self.gensizer.Add(self.alpha_choice, 1) self.id += 1 self.sample_x_choice = ['X' + str(f + 1) for f in features] x_title = GenStaticText(self, size=(100, -1), label="Choose X: ", style=wx.ALIGN_RIGHT) x_title.SetBackgroundColour((210, 210, 210)) self.x_values = np.zeros(len(features)) self.x_choice = wx.ComboBox(self, self.id, choices=self.sample_x_choice, style=wx.CB_READONLY) self.id += 1 self.x_value = wx.TextCtrl(self, self.id) self.x_value.SetBackgroundColour((210, 210, 210)) self.id += 1 self.gensizer.Add(x_title, 1) self.gensizer.Add(self.x_choice, 0) self.gensizer.Add(self.x_value, 1) self.alpha_choice.Bind(wx.EVT_COMBOBOX, self.on_alpha_choice_changed) self.x_value.Bind(wx.EVT_TEXT, self.on_x_value_changed) self.x_choice.Bind(wx.EVT_COMBOBOX, self.on_x_choice_changed)
def make_items(self): algo_title = GenStaticText(self, size=(150, -1), label=" Choose Algorithm: ", style=wx.ALIGN_RIGHT) algo_title.SetBackgroundColour((210, 210, 210)) self.algo_choice = wx.ComboBox(self, self.id, choices=self.sample_algo_choice, style=wx.CB_READONLY) self.id += 1 datasizer = wx.BoxSizer(wx.HORIZONTAL) self.dataset = wx.Button(self, self.id, size=(150, -1), label="Load Dataset") self.id += 1 datasizer.Add(self.dataset) self.subsizer1 = wx.BoxSizer(wx.VERTICAL) self.subsizer1.Add(datasizer, 0, wx.ALL, 5) subsubsizer1 = wx.BoxSizer(wx.HORIZONTAL) subsubsizer1.Add(algo_title, 1) subsubsizer1.Add(self.algo_choice, 1) lambdasizer = wx.BoxSizer(wx.HORIZONTAL) self.lamnda_title = GenStaticText(self, size=(100, -1), label=" Lambda: ", style=wx.ALIGN_RIGHT) self.lamnda_title.SetBackgroundColour((210, 210, 210)) self.show_lambda = wx.TextCtrl(self, self.id) self.show_lambda.SetBackgroundColour((210, 210, 210)) self.id += 1 self.run = wx.Button(self, self.id, size=(100, -1), label="Run") self.id += 1 lambdasizer.Add(self.lamnda_title, 1) lambdasizer.Add(self.show_lambda, 1) lambdasizer.Add(self.run, 1) degreesizer = wx.BoxSizer(wx.HORIZONTAL) self.degree_title = GenStaticText(self, size=(100, -1), label=" Degree: ", style=wx.ALIGN_RIGHT) self.degree_title.SetBackgroundColour((210, 210, 210)) self.show_degree = wx.TextCtrl(self, self.id) self.show_degree.SetBackgroundColour((210, 210, 210)) self.id += 1 degreesizer.Add(self.degree_title, 1) degreesizer.Add(self.show_degree, 1) self.subsizer1.Add(subsubsizer1, 0, wx.ALL, 5) self.subsizer1.Add(lambdasizer, 0, wx.ALL, 5) self.subsizer1.Add(degreesizer, 0, wx.ALL, 5) subsubsizer2 = wx.BoxSizer(wx.HORIZONTAL) test_title = GenStaticText(self, size=(100, -1), label="Test Values: ", style=wx.ALIGN_RIGHT) test_title.SetBackgroundColour((210, 210, 210)) self.test_value = wx.TextCtrl(self, style=wx.CB_READONLY) self.test_value.SetBackgroundColour((210, 210, 210)) subsubsizer2.Add(test_title, 1) subsubsizer2.Add(self.test_value, 4) self.subsizer2 = wx.BoxSizer(wx.VERTICAL) self.subsizer2.Add(subsubsizer2, 0, wx.ALL, 5) self.gensizer = wx.BoxSizer(wx.HORIZONTAL) x_values_title = GenStaticText(self, size=(100, -1), label=" X Values: ", style=wx.ALIGN_RIGHT) x_values_title.SetBackgroundColour((210, 210, 210)) self.show_x_values = wx.TextCtrl(self, self.id, style=wx.CB_READONLY) self.show_x_values.SetBackgroundColour((210, 210, 210)) self.id += 1 xvaluessizer = wx.BoxSizer(wx.HORIZONTAL) xvaluessizer.Add(x_values_title, 1) xvaluessizer.Add(self.show_x_values, 4) self.subsizer2.Add(xvaluessizer, 0, wx.ALL, 5) self.subsizer2.Add(self.gensizer, 0, wx.ALL, 5) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.subsizer1, 1, wx.EXPAND | wx.ALL, 5) sizer.Add(self.subsizer2, 2, wx.EXPAND | wx.ALL, 5) self.SetSizer(sizer) self.SetupScrolling() self.dataset.Bind(wx.EVT_BUTTON, self.on_load_dataset) self.run.Bind(wx.EVT_BUTTON, self.on_run_algo) self.algo_choice.Bind(wx.EVT_COMBOBOX, self.on_algo_changed)
class Panel_Controller(scrolled.ScrolledPanel): def __init__(self, parent): w, h = parent.GetSize() scrolled.ScrolledPanel.__init__(self, parent=parent, size=(w, 0.2 * h), style=wx.SUNKEN_BORDER) self.SetBackgroundColour((210, 210, 210)) self.parent = parent self.sample_algo_choice = [] self.id = 0 self.x_idx = -1 self.kind = -1 self.lbda = 1 self.deg = 6 self.make_items() def make_items(self): algo_title = GenStaticText(self, size=(150, -1), label=" Choose Algorithm: ", style=wx.ALIGN_RIGHT) algo_title.SetBackgroundColour((210, 210, 210)) self.algo_choice = wx.ComboBox(self, self.id, choices=self.sample_algo_choice, style=wx.CB_READONLY) self.id += 1 datasizer = wx.BoxSizer(wx.HORIZONTAL) self.dataset = wx.Button(self, self.id, size=(150, -1), label="Load Dataset") self.id += 1 datasizer.Add(self.dataset) self.subsizer1 = wx.BoxSizer(wx.VERTICAL) self.subsizer1.Add(datasizer, 0, wx.ALL, 5) subsubsizer1 = wx.BoxSizer(wx.HORIZONTAL) subsubsizer1.Add(algo_title, 1) subsubsizer1.Add(self.algo_choice, 1) lambdasizer = wx.BoxSizer(wx.HORIZONTAL) self.lamnda_title = GenStaticText(self, size=(100, -1), label=" Lambda: ", style=wx.ALIGN_RIGHT) self.lamnda_title.SetBackgroundColour((210, 210, 210)) self.show_lambda = wx.TextCtrl(self, self.id) self.show_lambda.SetBackgroundColour((210, 210, 210)) self.id += 1 self.run = wx.Button(self, self.id, size=(100, -1), label="Run") self.id += 1 lambdasizer.Add(self.lamnda_title, 1) lambdasizer.Add(self.show_lambda, 1) lambdasizer.Add(self.run, 1) degreesizer = wx.BoxSizer(wx.HORIZONTAL) self.degree_title = GenStaticText(self, size=(100, -1), label=" Degree: ", style=wx.ALIGN_RIGHT) self.degree_title.SetBackgroundColour((210, 210, 210)) self.show_degree = wx.TextCtrl(self, self.id) self.show_degree.SetBackgroundColour((210, 210, 210)) self.id += 1 degreesizer.Add(self.degree_title, 1) degreesizer.Add(self.show_degree, 1) self.subsizer1.Add(subsubsizer1, 0, wx.ALL, 5) self.subsizer1.Add(lambdasizer, 0, wx.ALL, 5) self.subsizer1.Add(degreesizer, 0, wx.ALL, 5) subsubsizer2 = wx.BoxSizer(wx.HORIZONTAL) test_title = GenStaticText(self, size=(100, -1), label="Test Values: ", style=wx.ALIGN_RIGHT) test_title.SetBackgroundColour((210, 210, 210)) self.test_value = wx.TextCtrl(self, style=wx.CB_READONLY) self.test_value.SetBackgroundColour((210, 210, 210)) subsubsizer2.Add(test_title, 1) subsubsizer2.Add(self.test_value, 4) self.subsizer2 = wx.BoxSizer(wx.VERTICAL) self.subsizer2.Add(subsubsizer2, 0, wx.ALL, 5) self.gensizer = wx.BoxSizer(wx.HORIZONTAL) x_values_title = GenStaticText(self, size=(100, -1), label=" X Values: ", style=wx.ALIGN_RIGHT) x_values_title.SetBackgroundColour((210, 210, 210)) self.show_x_values = wx.TextCtrl(self, self.id, style=wx.CB_READONLY) self.show_x_values.SetBackgroundColour((210, 210, 210)) self.id += 1 xvaluessizer = wx.BoxSizer(wx.HORIZONTAL) xvaluessizer.Add(x_values_title, 1) xvaluessizer.Add(self.show_x_values, 4) self.subsizer2.Add(xvaluessizer, 0, wx.ALL, 5) self.subsizer2.Add(self.gensizer, 0, wx.ALL, 5) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.subsizer1, 1, wx.EXPAND | wx.ALL, 5) sizer.Add(self.subsizer2, 2, wx.EXPAND | wx.ALL, 5) self.SetSizer(sizer) self.SetupScrolling() self.dataset.Bind(wx.EVT_BUTTON, self.on_load_dataset) self.run.Bind(wx.EVT_BUTTON, self.on_run_algo) self.algo_choice.Bind(wx.EVT_COMBOBOX, self.on_algo_changed) def make_test_items(self, features): self.alpha_title = GenStaticText(self, size=(100, -1), label="Choose Alpha: ", style=wx.ALIGN_RIGHT) self.alpha_title.SetBackgroundColour((210, 210, 210)) self.alpha_choice = wx.ComboBox(self, self.id, choices=[], style=wx.CB_READONLY) self.toggle_Coeffs([False, False]) self.gensizer.Add(self.alpha_title, 1) self.gensizer.Add(self.alpha_choice, 1) self.id += 1 self.sample_x_choice = ['X' + str(f + 1) for f in features] x_title = GenStaticText(self, size=(100, -1), label="Choose X: ", style=wx.ALIGN_RIGHT) x_title.SetBackgroundColour((210, 210, 210)) self.x_values = np.zeros(len(features)) self.x_choice = wx.ComboBox(self, self.id, choices=self.sample_x_choice, style=wx.CB_READONLY) self.id += 1 self.x_value = wx.TextCtrl(self, self.id) self.x_value.SetBackgroundColour((210, 210, 210)) self.id += 1 self.gensizer.Add(x_title, 1) self.gensizer.Add(self.x_choice, 0) self.gensizer.Add(self.x_value, 1) self.alpha_choice.Bind(wx.EVT_COMBOBOX, self.on_alpha_choice_changed) self.x_value.Bind(wx.EVT_TEXT, self.on_x_value_changed) self.x_choice.Bind(wx.EVT_COMBOBOX, self.on_x_choice_changed) def updated_algo_choice(self, samples): self.sample_algo_choice = samples self.algo_choice.Clear() for sample in self.sample_algo_choice: self.algo_choice.Append(sample) def updated_alpha_choice(self, samples): self.sample_alpha_choice = samples self.alpha_choice.Clear() for sample in self.sample_alpha_choice: self.alpha_choice.Append(sample) def updated_x_choice(self, samples): self.sample_x_choice = ['X' + str(f + 1) for f in samples] self.x_choice.Clear() for sample in self.sample_x_choice: self.x_choice.Append(sample) def on_load_dataset(self, evt): dirname = "" # set directory name to blank dlg = wx.FileDialog(self, "Choose a file to open", dirname, "", "*.*", wx.OPEN) # open the dialog boxto open file if dlg.ShowModal() == wx.ID_OK: # if positive button selected.... filename = dlg.GetFilename() # get the filename of the file dirname = dlg.GetDirectory( ) # get the directory of where file is located self.load_dataset(filename, dirname) else: pass dlg.Destroy() if self.parent.panel_plotting_helper: self.parent.panel_plotting_helper.fig.clf() self.parent.panel_plotting_helper.update_canvas() else: pass self.updated_x_choice(self.parent.mlt.features) self.x_values = np.zeros(len(self.parent.mlt.features)) self.x_idx = -1 self.kind = -1 self.delete_attributes() def load_dataset(self, fileName, dirName=None): if dirName: self.parent.mlt.LoadData( os.path.join(dirName, fileName) ) # traverse the file directory and find filename in the OS else: self.parent.mlt.LoadData( os.path.join(os.path.dirname(__file__), fileName)) def on_algo_changed(self, evt): self.algo_idx = evt.GetSelection() if self.parent.mlt: self.do_stuff(self.algo_idx) self.delete_attributes() self.result = self.parent.mlt.result if self.sample_algo_choice[ self.algo_idx] == 'LrByGradientDescent' and len( self.result.keys()) > 1: self.updated_alpha_choice(self.result.keys()) self.toggle_Coeffs([True, False]) self.kind = 0 elif self.sample_algo_choice[ self.algo_idx] == 'LrByNormalEquation': self.toggle_Coeffs([False, False]) self.kind = 0 self.theta = self.result['0']['theta'] self.estimate_y() elif self.sample_algo_choice[self.algo_idx] == 'LrByMinimizeCost': self.toggle_Coeffs([False, False]) self.kind = 1 self.theta = self.result['0']['theta'] self.instance = self.result['0']['instance'] self.estimate_y() elif self.sample_algo_choice[ self.algo_idx] == 'LrByMinimizeCostRegular': self.toggle_Coeffs([False, True]) self.kind = 1 self.show_lambda.SetValue(str(self.lbda)) self.show_degree.SetValue(str(self.deg)) self.theta = self.result['0']['theta'] self.instance = self.result['0']['instance'] self.estimate_y() else: self.toggle_Coeffs([False, False]) self.kind = -1 else: pass def delete_attributes(self): self.sample_alpha_choice = [] self.x_choice.SetSelection(self.x_idx) self.x_value.SetValue(str(self.x_values[self.x_idx])) self.lbda = 1 self.deg = 6 if hasattr(self, 'theta'): del self.theta else: pass if hasattr(self, 'mean'): del self.mean else: pass if hasattr(self, 'std'): del self.std else: pass if hasattr(self, 'instance'): del self.instance else: pass self.show_x_values.SetValue('') self.test_value.SetValue('') self.parent.statusbar.SetStatusText('') def toggle_Coeffs(self, isShown): if isShown[0]: self.alpha_title.Enable() self.alpha_choice.Enable() else: self.alpha_title.Disable() self.alpha_choice.Disable() if isShown[1]: self.lamnda_title.Enable() self.show_lambda.Enable() self.run.Enable() self.degree_title.Enable() self.show_degree.Enable() else: self.lamnda_title.Disable() self.show_lambda.Disable() self.run.Disable() self.degree_title.Disable() self.show_degree.Disable() def on_alpha_choice_changed(self, evt): idx = evt.GetSelection() alpha = self.sample_alpha_choice[idx] self.theta = self.result[alpha]['theta'] self.mean = self.result[alpha]['mean'] self.std = self.result[alpha]['std'] self.estimate_y() def on_x_choice_changed(self, evt): self.x_idx = evt.GetSelection() self.x_value.SetValue(str(self.x_values[self.x_idx])) def on_run_algo(self, evt): try: self.lbda = float(self.show_lambda.GetValue()) self.deg = int(self.show_degree.GetValue()) self.parent.statusbar.SetStatusText('') except ValueError: print(ValueError) self.parent.statusbar.SetStatusText( 'You must enter a number!!! Please') self.do_stuff(self.algo_idx, self.lbda, self.deg) self.result = self.parent.mlt.result self.theta = self.result['0']['theta'] self.estimate_y() def on_x_value_changed(self, evt): if self.x_idx in range(len(self.x_values)) and hasattr(self, 'theta'): try: self.x_values[self.x_idx] = self.x_value.GetValue() self.parent.statusbar.SetStatusText('') self.estimate_y() except ValueError: print(ValueError) self.parent.statusbar.SetStatusText( 'You must enter a number!!! Please') else: pass # self.show_x_values.SetValue('Your test x_array is ' + str(self.x_values)) def estimate_y(self): xx = np.zeros((1, len(self.x_values) + 1)) xx[0, 0] = 1 for i in range(len(self.x_values)): xx[0, i + 1] = self.x_values[i] if hasattr(self, 'mean') and hasattr(self, 'std'): for i in range(len(self.x_values)): xx[0, i + 1] = (self.x_values[i] - self.mean[i]) / self.std[i] else: pass y = self.compute_y(xx) self.test_value.SetValue(str(y)) xVals = str(xx[0, 0]) for v in self.x_values: xVals += ', ' + str(v) self.show_x_values.SetValue('[ %r]' % xVals) def compute_y(self, xx): if self.kind == 0: return np.dot(xx, self.theta) elif self.kind == 1: return self.instance.estimate(xx, self.theta, self.deg) else: return '' def do_stuff(self, idx, coeff=None, deg=None): start = time.time() method_call = getattr(self.parent.mlt, self.sample_algo_choice[idx]) method_call(None, None, coeff, deg) end = time.time() print("Time consumed of %s: %s sec \n\n" % (self.sample_algo_choice[idx], end - start))
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)
def SetBackgroundColour(self, colour): GenStaticText.SetBackgroundColour(self, colour) self.Refresh()
def getDefaultTextField(self, t=""): text = StaticText(self, -1, t) text.SetForegroundColour(wx.WHITE) text.SetBackgroundColour(self.guiUtility.triblerRed) return text