def __init__(self, daddy, parent, attack): self.win = daddy self.attack = attack wx.ScrolledWindow.__init__(self,parent,id=-1) self.Bind(wx.EVT_SIZE, self.OnSize) self.Image = wx.StaticBitmap(self, -1, wx.EmptyBitmap(1,1)) self.box = wx.BoxSizer(wx.VERTICAL) self.box.Add(self.Image,1,wx.ALIGN_CENTER) self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.hbox.Add(self.box,1,wx.ALIGN_CENTER) self.SetSizer(self.hbox) self.original = None filename = attack.file if attack.filetype == "png": self.original = wx.Image(filename,wx.BITMAP_TYPE_PNG) elif attack.filetype == "ps": # depends on PIL lib try: self.original = Image.open(filename) except: Preference.doNotUsePIL() raise Error.PILError else: print "Unknown file type %s." % (self.filetype) # TODO self.Bind(wxSizeEvent self.update(True) self.Fit()
def mytoggle(btn, pref, event): res = btn.GetValue() if res == True: val = 1 else: val = 0 Preference.set(pref, val) SSRpropagate()
def ScytherArguments(self, mode): """ Note: constructed strings should have a space at the end to correctly separate the options. """ tstr = "" # Number of runs tstr += "--max-runs=%s " % (str(self.maxruns)) # Matching type tstr += "--match=%s " % (str(self.match)) # Compromise type #tstr += "--local-compromise=%s " % (str(self.localcompromise)) # Partner definition #tstr += "--partner-definition=%s " % (str(self.partnerdefinition)) # Prune (has to go BEFORE max attacks) tstr += "--prune=%s" % (str(self.prune)) # Max attacks/classes if self.maxattacks != 0: tstr += "--max-attacks=%s " % (str(self.maxattacks)) # Take standard arguments for pk in Preference.getkeys(): if pk.startswith("--"): # Switch type preference if pk.endswith("="): # Argument tstr += "%s%s " % (pk, Preference.get(pk)) else: # Just enabling if 1 or True val = Preference.get(pk) if val == True or (int(val) == 1): tstr += "%s " % pk # Parse LKR after type lkratype = int(Preference.get("LKRafter")) lkratxt = ["", "--LKRaftercorrect=1 ", "--LKRafter=1 "] tstr += lkratxt[lkratype] # Verification type if mode == "check": tstr += "--check " elif mode == "autoverify": tstr += "--auto-claims " elif mode == "characterize": tstr += "--state-space " # Anything else? if self.misc != "": tstr += " " + self.misc + " " return str( tstr) # turn it into a str (might have been unicode weirdness)
def beforegui(win): import Preference from modules import Globals win.pref = Preference.Preference() win.pref.load() win.pref.printValues() Globals.pref = win.pref
def toggler(description, buttontxt, pref): oldstate = Preference.get(pref, 0) desc = wx.StaticText(self, -1, description) btn = wx.CheckBox(self, -1, buttontxt) btn.SetValue(int(oldstate) == 1) tf = lambda event: mytoggle(btn, pref, event) self.Bind(wx.EVT_CHECKBOX, tf, btn) grid.stepAdd(btn, desc) return btn
def __init__(self, applet, iid): """Create applet for Forismatic Notify""" self.applet=applet self.iid=iid self.conf = Preference.Config(applet,self.cb_TimePeriod,self.cb_Theme,self.cb_Lang) (self.TimePeriod, self.Theme,self.Language) =\ self.conf.get_settings() self.theme_path = os.path.join(path,'Themes',self.Theme) self.time = self.TimePeriod*60 if self.time==0: self.time = 300 GnomeAppletSkeleton.__init__(self, applet, iid)
def __init__(self, parent, size=(850, 500), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): self.initmixin() #config.ini self.ini = common.get_config_file_obj() wx.Dialog.__init__(self, parent, -1, title=tr("Preferences"), size=size, style=style) self.value_set = [] self.pages = {} self.pagenames = {} self.values = {} self.parent = parent self.pref = self.parent.pref self.default_pref = Preference.Preference() self.box = box = ui.VBox(namebinding='widget') self.treebook = TreeBookPanel(self, -1) self.addPages(self.treebook) box.add(self.treebook, proportion=1, flag=wx.EXPAND | wx.ALL) box.add(wx.StaticLine(self), flag=wx.EXPAND | wx.ALL) buttons = [(tr('OK'), wx.ID_OK, 'btnOk'), (tr('Cancel'), wx.ID_CANCEL, 'btnCancel'), (tr('Apply'), wx.ID_APPLY, 'btnApply')] box.add(ui.simple_buttons(buttons), flag=wx.ALIGN_CENTER | wx.BOTTOM) box.bind('btnOk', 'click', self.OnOk) box.bind('btnApply', 'click', self.OnApply) self.create_pages() self.callplugin('initpreference', self) ui.create(self, box, 0) self.btnOk.SetDefault() self.treebook.select() self.values = self.get_values() wx.EVT_UPDATE_UI(self, self.btnApply.GetId(), self.OnUpdateApply) self.callplugin('aftercreate', self)
def makeImageDot(dotdata,attackthread=None): """ create image for this particular dot data """ if Preference.usePIL(): # If we have the PIL library, we can do postscript! great # stuff. type = "ps" ext = ".ps" else: # Ye olde pnge file type = "png" ext = ".png" # Retrieve dot command path dotcommand = FindDot.findDot() # command to write to temporary file (fd2,fpname2) = Temporary.tempcleaned(ext) f = os.fdopen(fd2,'w') # Set up command cmd = "%s -T%s" % (dotcommand,type) # execute command p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE) if attackthread: writeGraph(attackthread,dotdata,p.stdin) else: p.stdin.write(dotdata) p.stdin.close() for l in p.stdout.read(): f.write(l) p.stdout.close() f.flush() f.close() return (fpname2, type)
def claimFixViewOne(self, claims): """ This is a stupid hack as long as switches.useAttackBuffer in Scyther C code is false. It is currently false because Windows VISTA screwed up the standard C function tmpfile() (It's in a directory to which normal users cannot write...) """ # TODO Notice the stupid default setting too ('2') which is # needed here. This really needs cleanup. if int(Preference.get('prune', '2')) != 0: if claims: for cl in claims: if len(cl.attacks) > 1: # Fix it such that by default, only the best attack is # shown, unless we are in characterize or check mode # TODO [X] [CC] make switch-dependant. if not self.mode in ["characterize", "check"]: cl.attacks = [cl.attacks[-1]] """ Cutting invalidates exactness of attack/behaviour counts """ cl.complete = False return claims
def claimFixViewOne(self,claims): """ This is a stupid hack as long as switches.useAttackBuffer in Scyther C code is false. It is currently false because Windows VISTA screwed up the standard C function tmpfile() (It's in a directory to which normal users cannot write...) """ # TODO Notice the stupid default setting too ('2') which is # needed here. This really needs cleanup. if int(Preference.get('prune','2')) != 0: if claims: for cl in claims: if len(cl.attacks) > 1: # Fix it such that by default, only the best attack is # shown, unless we are in characterize or check mode # TODO [X] [CC] make switch-dependant. if not self.mode in ["characterize","check"]: cl.attacks = [cl.attacks[-1]] """ Cutting invalidates exactness of attack/behaviour counts """ cl.complete = False return claims
def CreateInteriorWindowComponents(self): ''' Create "interior" window components. In this case it is the attack picture. ''' sizer = wx.BoxSizer(wx.VERTICAL) # Make zoom buttons if Preference.usePIL(): buttons = wx.BoxSizer(wx.HORIZONTAL) bt = wx.ToggleButton(self,-1,"Fit to window") bt.SetValue(self.fit) buttons.Add(bt,0) self.Bind(wx.EVT_TOGGLEBUTTON, self.OnFit, bt) sizer.Add(buttons, 0, wx.ALIGN_LEFT) # Add attacks (possible with tabs) self.displays=[] attacks = self.claim.attacks n = len(attacks) if n <= 1: # Just a single window dp = AttackDisplay(self, self, attacks[0]) self.displays.append(dp) else: # Multiple tabs dp = wx.Notebook(self,-1) for i in range(0,n): disp = AttackDisplay(self,dp,attacks[i]) classname = "%s %i" % (self.claim.stateName(1,True),(i+1)) dp.AddPage(disp, classname) self.displays.append(disp) sizer.Add(dp, 1, wx.EXPAND,1) self.SetSizer(sizer)
def myradio(rdb, pref, event): Preference.set(pref, int(rdb.GetSelection()))
def __init__(self,parent,daddy): wx.Panel.__init__(self,parent,-1) self.win = daddy # layout the stuff grid = MyGrid(self) ### Parameters grid.titleAdd("Verification parameters",False) # Bound on the number of runs self.maxruns = int(Preference.get('maxruns','5')) txt = wx.StaticText(self,-1,"Maximum number of runs\n(0 disables bound)") ctrl = wx.SpinCtrl(self, -1, "",style=wx.RIGHT) ctrl.SetRange(0,100) ctrl.SetValue(self.maxruns) self.Bind(wx.EVT_SPINCTRL,self.EvtRuns,ctrl) grid.stepAdd(ctrl,txt) # Matchin options self.match = int(Preference.get('match','0')) claimoptions = ['typed matching','find basic type flaws','find all type flaws'] r2 = wx.StaticText(self,-1,"Matching type") l2 = self.ch = wx.Choice(self,-1,choices=claimoptions) l2.SetSelection(self.match) self.Bind(wx.EVT_CHOICE,self.EvtMatch,l2) grid.stepAdd(l2,r2) ### MISC expert stuff grid.titleAdd("Advanced parameters") # Continue after finding the first attack self.prune = int(Preference.get('prune','2')) claimoptions = ['Find all attacks','Find first attack','Find best attack'] r8 = wx.StaticText(self,-1,"Search pruning") l8 = self.ch = wx.Choice(self,-1,choices=claimoptions) l8.SetSelection(self.prune) self.Bind(wx.EVT_CHOICE,self.EvtPrune,l8) grid.stepAdd(l8,r8) # Bound on the number of patterns self.maxattacks = int(Preference.get('maxattacks','10')) r9 = wx.StaticText(self,-1,"Maximum number of patterns\nper claim") l9 = wx.SpinCtrl(self, -1, "",style=wx.RIGHT) l9.SetRange(0,100) l9.SetValue(self.maxattacks) self.Bind(wx.EVT_SPINCTRL,self.EvtMaxAttacks,l9) grid.stepAdd(l9,r9) self.misc = Preference.get('scytheroptions','') r10 = wx.StaticText(self,-1,"Additional backend parameters") l10 = wx.TextCtrl(self,-1,self.misc,size=(200,-1)) self.Bind(wx.EVT_TEXT,self.EvtMisc,l10) grid.stepAdd(l10,r10) ### Graph output stuff grid.titleAdd("Graph output parameters") # Bound on the number of classes/attacks if sys.platform.startswith("lin"): defsize = 14 else: defsize = 11 self.fontsize = int(Preference.get('fontsize',defsize)) txt = wx.StaticText(self,-1,"Attack graph font size\n(in points)") ctrl = wx.SpinCtrl(self, -1, "",style=wx.RIGHT) ctrl.SetRange(6,32) ctrl.SetValue(self.fontsize) self.Bind(wx.EVT_SPINCTRL,self.EvtFontsize,ctrl) grid.stepAdd(ctrl,txt) ### Combine grid.lineAdd() self.SetSizer(grid) self.SetAutoLayout(True)
def EvtPrune(self,evt): self.prune = evt.GetInt() Preference.set('prune',self.prune)
"""with codecs.open(saved_quote_path, encoding='utf-8',mode='w') as file_w: file_w.write(quoteText) file_w.write("\n"+quoteAuthor) file_w.closed""" #write to GConf self.conf.set_Quote(quoteText, quoteAuthor, quoteLink) #print "%s \n %s \n %s "%(quoteText, quoteAuthor, quoteLink) #print "end" def quote_lang(self): """Return current language for quote""" self.Language = self.conf.get_settings()[2] if self.Language == 'English' or self.Language == 'english' \ or self.Language == 'en': return 'en' elif self.Language == 'Russian' or self.Language == 'russian' \ or self.Language == 'ru': return 'ru' else: return None if __name__ == '__main__': import Preference conf = Preference.Config() path = os.getcwd() quote = Forismatic(conf, path) quote.save_qote()
def main(link, pref_type): """Shows basic usage of the Sheets API. Prints values from a sample spreadsheet. """ # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. SAMPLE_SPREADSHEET_ID = link SAMPLE_RANGE_NAME = 'Form Responses 1' store = file.Storage('token.json') creds = store.get() if not creds or creds.invalid: flow = client.flow_from_clientsecrets('credentials.json', SCOPES) creds = tools.run_flow(flow, store) service = build('sheets', 'v4', http=creds.authorize(Http())) # Call the Sheets API sheet = service.spreadsheets() result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID, range=SAMPLE_RANGE_NAME).execute() values = result.get('values', []) pref_list = [] index = 0 result = [] assignee_list = [] task_list = [] authority_list = [] authorities = [] tasks = [] if pref_type is 'Assignee': if not values: print('No data found.') else: for row in values: # Print columns A and E, which correspond to indices 0 and 4. #print('%s, %s' % (row[0], row[1])) if index is 0: index = index + 1 continue else: assignee_email = row[1] id = row[2] pref_list = row[3:6]#manually written rank = 1 teaching_assistant = ta.TeachingAssistant(id, '--', '--', '--') assignee_list.append(teaching_assistant) for task_id in pref_list: pref = p.Preference(None, id, task_id, rank) rank = rank + 1 result.append(pref) index = index + 1 return result, assignee_list if 'High Authority' in pref_type: if not values: print('No data found.') else: for row in values: # Print columns A and E, which correspond to indices 0 and 4. #print('%s, %s' % (row[0], row[1])) if index is 0: index = index + 1 continue else: authority_email = row[1] authority_id = row[2] task_id = row[3] tasks.append(task_id) task_requirement = row[4] if authority_id not in authorities: authority = ins.Instructor(authority_id, '--', [], [], '--') authority_list.append(authority) cou = c.Course(task_id, '--', '--', authority_id, task_requirement) authority.courses.append(cou) task_list.append(cou) else: loc = authorities.index(authority_id) aut = authority_list.get(loc) cou = c.Course(task_id, '--', '--', authority_id, task_requirement) aut.courses.append(cou) task_list.append(cou) pref_list = row[5:18] #manually written rank = 1 for assignee_id in pref_list: pref = p.Preference(authority_id, assignee_id, task_id, rank) rank = rank + 1 result.append(pref) index = index + 1 return result, authority_list, task_list, tasks
def SSRpropagate(): val = Preference.get("--SSR=") if (val == True) or (int(val) == 1): InferToggle.Enable() else: InferToggle.Enable(False)
def createPreference(self, id, ta_id, course_id, rank): pref = p.Preference(id, ta_id, course_id, rank) self.preferences.append(pref)
def __init__(self, parent, daddy): wx.Panel.__init__(self, parent, -1) self.win = daddy # layout the stuff grid = MyGrid(self) ### Parameters grid.titleAdd("Verification parameters", False) # Bound on the number of runs self.maxruns = int(Preference.get('maxruns', '5')) txt = wx.StaticText(self, -1, "Maximum number of runs\n(0 disables bound)") ctrl = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) ctrl.SetRange(0, 100) ctrl.SetValue(self.maxruns) self.Bind(wx.EVT_SPINCTRL, self.EvtRuns, ctrl) grid.stepAdd(ctrl, txt) # Matchin options self.match = int(Preference.get('match', '0')) claimoptions = [ 'typed matching', 'find basic type flaws', 'find all type flaws' ] r2 = wx.StaticText(self, -1, "Matching type") l2 = self.ch = wx.Choice(self, -1, choices=claimoptions) l2.SetSelection(self.match) self.Bind(wx.EVT_CHOICE, self.EvtMatch, l2) grid.stepAdd(l2, r2) ### Security model grid.titleAdd("Adversary compromise model") ## Partner definition #self.partnerdefinition = int(Preference.get('partnerdefinition','1')) #claimoptions = ['Temporal (Experimental)','Matching conversations','Session identifier (SID)'] #r4 = wx.StaticText(self,-1,"Partner definition") #l4 = self.ch = wx.Choice(self,-1,choices=claimoptions) #l4.SetSelection(self.partnerdefinition) #self.Bind(wx.EVT_CHOICE,self.EvtPartnerdefinition,l4) #grid.stepAdd(l4,r4) # Propagate choice for SSR def SSRpropagate(): val = Preference.get("--SSR=") if (val == True) or (int(val) == 1): InferToggle.Enable() else: InferToggle.Enable(False) # Toggle stuff def mytoggle(btn, pref, event): res = btn.GetValue() if res == True: val = 1 else: val = 0 Preference.set(pref, val) SSRpropagate() # Checkboxes def toggler(description, buttontxt, pref): oldstate = Preference.get(pref, 0) desc = wx.StaticText(self, -1, description) btn = wx.CheckBox(self, -1, buttontxt) btn.SetValue(int(oldstate) == 1) tf = lambda event: mytoggle(btn, pref, event) self.Bind(wx.EVT_CHECKBOX, tf, btn) grid.stepAdd(btn, desc) return btn toggler("Long-term Key Reveal", "Others (DY)", "--LKRothers=") # myradio def myradio(rdb, pref, event): Preference.set(pref, int(rdb.GetSelection())) toggler("Long-term Key Reveal", "Actor (KCI)", "--LKRactor=") # LKRaftercorrect variants desc = wx.StaticText(self, -1, " Long-term Key Reveal after claim") options = ['None (DY)', 'aftercorrect (wPFS)', 'after (PFS)'] rdb = wx.RadioBox(self, -1, "", (10, 10), wx.DefaultSize, options, 1) rdb.SetSelection(int(Preference.get("LKRafter"))) self.Bind(wx.EVT_RADIOBOX, lambda event: myradio(rdb, "LKRafter", event), rdb) grid.stepAdd(rdb, desc) toggler("Session-Key Reveal", "", "--SKR=") toggler("Random Reveal", "", "--RNR=") toggler("State Reveal", "", "--SSR=") InferToggle = toggler(" Automatically infer local state", "", "--SSRinfer=") SSRpropagate() ### MISC expert stuff grid.titleAdd("Advanced parameters") # Continue after finding the first attack self.prune = int(Preference.get('prune', '2')) claimoptions = [ 'Find all attacks', 'Find first attack', 'Find best attack' ] r8 = wx.StaticText(self, -1, "Search pruning") l8 = self.ch = wx.Choice(self, -1, choices=claimoptions) l8.SetSelection(self.prune) self.Bind(wx.EVT_CHOICE, self.EvtPrune, l8) grid.stepAdd(l8, r8) # Bound on the number of patterns self.maxattacks = int(Preference.get('maxattacks', '10')) r9 = wx.StaticText(self, -1, "Maximum number of patterns\nper claim") l9 = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) l9.SetRange(0, 100) l9.SetValue(self.maxattacks) self.Bind(wx.EVT_SPINCTRL, self.EvtMaxAttacks, l9) grid.stepAdd(l9, r9) self.misc = Preference.get('scytheroptions', '') r10 = wx.StaticText(self, -1, "Additional backend parameters") l10 = wx.TextCtrl(self, -1, self.misc, size=(200, -1)) self.Bind(wx.EVT_TEXT, self.EvtMisc, l10) grid.stepAdd(l10, r10) ### Graph output stuff grid.titleAdd("Graph output parameters") # Bound on the number of classes/attacks if sys.platform.startswith("lin"): defsize = 14 else: defsize = 11 self.fontsize = int(Preference.get('fontsize', defsize)) txt = wx.StaticText(self, -1, "Attack graph font size\n(in points)") ctrl = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) ctrl.SetRange(6, 32) ctrl.SetValue(self.fontsize) self.Bind(wx.EVT_SPINCTRL, self.EvtFontsize, ctrl) grid.stepAdd(ctrl, txt) ### Combine grid.lineAdd() self.SetSizer(grid) self.SetAutoLayout(True)
def MainInitOnce(): result = Preference.usePIL() # Makes sure PIL is tested.
def scheduling(): # for test checkIsTrue() getData() # for node in nodeList: # node.setData(10.0) # nodeList[4].setData(49) for node in nodeList: for edge in edgeList: checkBLE = True pr = Preference.Preference(node, edge, checkBLE) node.addPreferenceList(pr) for node in nodeList: node.connectMostPreferEdge() for edge in edgeList: edge.stabilizeQueue() while isFinished() == False: for node in nodeList: if (node.isConnected == False): node.connectMostPreferEdge() if node.connectType != 0: node.connectedEdge.stabilizeQueue() for edge in edgeList: print(edge.name, "의 연결 노드 :") for conn in edge.connectedList: print(conn.node.name, ',', conn.node.connectType) sock_edge = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock_iot = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for edge in edgeList: data = '' for conn in edge.connectedList: data += conn.node.name if conn.node.connectType == 0: data += '_none' elif conn.node.connectType == 1: data += '_ble' elif conn.node.connectType == 2: data += '_wifi' data += ',' data = data[:-1] print(data) sock_edge.sendto(data.encode(), (edge.IP, edge.PORT)) edge.setReady(False) node_power = {str(): float()} node_queue = {str(): float()} for node in nodeList: data = '' data += node.connectedEdge.name if node.connectType == 0: data += '_none' node_power[node.name] = 0.0 elif node.connectType == 1: data += '_ble' data += ',' data += str(node.processSize) data += ',' if node.processSize > 0.6: data += '2' node_power[node.name] = 260.0 else: data += '1' node_power[node.name] = 130.0 elif node.connectType == 2: data += '_wifi' data += ',' data += str(node.processSize) node_power[node.name] = 270.0 node_queue[node.name] = (node.dataQueue - node.processSize) sock_iot.sendto(data.encode(), (node.IP, node.PORT)) node.setReady(False) node.getData = False log_queue_writer.writerow(node_queue) log_power_writer.writerow(node_power) threading.Timer(5 * 60, scheduling)
def __init__(self): """ initializing ui """ filePath = os.path.dirname(os.path.abspath(__file__)) imagesPath = os.path.join(filePath, 'images') iconSize = 25 marginSize = 0 #Preference self.pref = Preference.Preference() self.win = cmds.window('DrawArcToolBar', width=500, title='MotionTrail Tool Option') self.frameLayoutMain = cmds.frameLayout(labelVisible=False, w=10, borderVisible=False, parent=self.win) self.rowLayoutMain = cmds.rowLayout(numberOfColumns=3, adjustableColumn=1, columnAttach=([1, 'right', 0]), parent=self.frameLayoutMain) cmds.rowLayout(numberOfColumns=6) ### cmds.columnLayout(width=200) ## cmds.rowLayout(numberOfColumns=3) # self.buttonLineColor = cmds.button(width=15, height=15, label='', backgroundColor=self.pref.lineColor, c=self.lineColor) cmds.text(label="line width", width=130) self.textFieldLineWidth = cmds.textField(text=round( self.pref.lineWidth, 2), width=40, cc=self.lineWidthCB) cmds.setParent("..") # self.floatSliderLineWidth = cmds.floatSlider( min=0, max=20, width=200, value=self.pref.lineWidth, step=0.1, annotation='Line Width of the MotionTrail.', dc=self.lineWidth) cmds.setParent("..") ## cmds.columnLayout(width=200) ## cmds.rowLayout(numberOfColumns=3) # self.buttonDotColor = cmds.button(width=15, height=15, label='', backgroundColor=self.pref.dotColor, c=self.dotColor) cmds.text(label="dot size", width=130) self.textFieldDotSize = cmds.textField(text=round( self.pref.dotSize, 2), width=40, cc=self.dotSizeCB) cmds.setParent("..") # self.floatSliderDotSize = cmds.floatSlider( min=0, max=20, width=200, value=self.pref.dotSize, step=0.01, annotation='Dot Size of the MotionTrail.', dc=self.dotSize) cmds.setParent("..") ## cmds.columnLayout(width=200) ## cmds.rowLayout(numberOfColumns=3) # self.buttonKeyFrameColor = cmds.button( width=15, height=15, label='', backgroundColor=self.pref.keyFrameColor, c=self.keyFrameColor) cmds.text(label="keyframe size", width=130) self.textFieldKeyFrameSize = cmds.textField(text=round( self.pref.keyFrameSize, 2), width=40, cc=self.keyFrameSizeCB) cmds.setParent("..") # self.floatSliderKeyFrameSize = cmds.floatSlider( min=0, max=20, width=200, value=self.pref.keyFrameSize, step=0.01, annotation='KeyFrame Size of the MotionTrail.', dc=self.keyFrameSize) cmds.setParent("..") ## cmds.columnLayout(width=200) ## cmds.rowLayout(numberOfColumns=3) # self.buttonTimeBufferColor = cmds.button( width=15, height=15, label='', backgroundColor=self.pref.timeBufferColor, c=self.timeBufferColor) cmds.text(label="timebuffer size", width=140) self.textFieldTimeBuffer = cmds.textField(text=round( self.pref.timeBuffer, 0), width=40, cc=self.timeBufferSizeCB) cmds.setParent("..") # self.floatSliderTimeBufferSize = cmds.floatSlider( min=0, max=50, width=200, value=self.pref.timeBuffer, step=1, annotation='Time Buffer size.', dc=self.timeBufferSize) cmds.setParent("..") ## cmds.rowLayout(numberOfColumns=3) ## cmds.separator(hr=False, height=10, width=10, style="none") self.optionMenuStyle = cmds.optionMenu(label='Style', cc=self.styleCB) self.menuItemDouble = cmds.menuItem(label='Double') self.menuItemSingle = cmds.menuItem(label='Single') self.optionMenuStyle = cmds.optionMenu(self.optionMenuStyle, e=True, value=self.pref.mtStyle) cmds.setParent("..") ## cmds.setParent("..") ### cmds.rowLayout(numberOfColumns=5) cmds.separator(hr=False, height=10, width=10, style="none") self.buttonSave = cmds.button(label="Save as Default", c=self.saveAsDefault) cmds.separator(hr=False, height=10, width=10, style="none") self.buttonClose = cmds.iconTextButton( style='iconOnly', image1=os.path.join(imagesPath, 'close.png'), hi=os.path.join(imagesPath, 'close_hi.png'), width=iconSize, mw=marginSize, height=iconSize, mh=marginSize, label='close', annotation='Closing Selection ToolBar', c=self.close)
def show_preferences(self,*arguments): """Show Preference windows""" print path self.pref = Preference.Preference(self.applet, path)
def EvtPrune(self, evt): self.prune = evt.GetInt() Preference.set('prune', self.prune)
def __init__(self, parent=None): """Constructor""" super(PreferenceUI, self).__init__(parent=parent) self.windowName = "preference_window" self.pref = Preference.Preference() mainLayout = QVBoxLayout() layoutIconSize = QGridLayout() labelIconSize = QLabel("Icon Size") self.lineEditIconSize = QLineEdit("") self.lineEditIconSize.setFixedWidth(80) self.lineEditIconSize.setText(str(self.pref.iconSize)) layoutIconSize.addWidget(labelIconSize, 0, 0) layoutIconSize.addWidget(self.lineEditIconSize, 0, 1) #layoutIconSize.setSpacing(20) layoutSplitter1 = QHBoxLayout() splitter1 = QSplitter(QtCore.Qt.Horizontal) splitter1.setStretchFactor(1, 10) layoutSplitter1.addWidget(splitter1) layoutLineWidth = QGridLayout() labelLineWidth = QLabel("Motion Trail Line Width") self.lineEditLineWidth = QLineEdit("") self.lineEditLineWidth.setFixedWidth(80) self.lineEditLineWidth.setText(str(round(self.pref.lineWidth, 2))) layoutLineWidth.addWidget(labelLineWidth, 0, 0) layoutLineWidth.addWidget(self.lineEditLineWidth, 0, 1) layoutDotSize = QGridLayout() labelDotSize = QLabel("Motion Trail Dot Size") self.lineEditDotSize = QLineEdit("") self.lineEditDotSize.setFixedWidth(80) self.lineEditDotSize.setText(str(round(self.pref.dotSize, 2))) layoutDotSize.addWidget(labelDotSize, 0, 0) layoutDotSize.addWidget(self.lineEditDotSize, 0, 1) layoutKeyFrame = QGridLayout() labelKeyFrame = QLabel("Motion Trail KeyFrame Size") self.lineEditKeyFrame = QLineEdit("") self.lineEditKeyFrame.setFixedWidth(80) self.lineEditKeyFrame.setText(str(round(self.pref.keyFrameSize, 2))) layoutKeyFrame.addWidget(labelKeyFrame, 0, 0) layoutKeyFrame.addWidget(self.lineEditKeyFrame, 0, 1) #layoutKeyFrame.setSpacing(18) layoutTimeBuffer = QGridLayout() labelTimeBuffer = QLabel("Motion Trail Time Bufffe Size") self.lineEditTimeBuffer = QLineEdit("") self.lineEditTimeBuffer.setFixedWidth(80) self.lineEditTimeBuffer.setText( str(round(self.pref.timeBuffer, 0)).split('.')[0]) layoutTimeBuffer.addWidget(labelTimeBuffer, 0, 0) layoutTimeBuffer.addWidget(self.lineEditTimeBuffer, 0, 1) #layoutTimeBuffer.setSpacing(18) buttonApply = QPushButton('Apply') mainLayout.addLayout(layoutIconSize, stretch=1) mainLayout.addLayout(layoutSplitter1, stretch=1) mainLayout.addLayout(layoutLineWidth, stretch=1) mainLayout.addLayout(layoutDotSize, stretch=1) mainLayout.addLayout(layoutKeyFrame, stretch=1) mainLayout.addLayout(layoutTimeBuffer, stretch=1) mainLayout.addWidget(buttonApply) self.setLayout(mainLayout) #- connect signal buttonApply.clicked.connect(self.apply)
def __init__(self, parent, daddy): wx.Panel.__init__(self, parent, -1) self.win = daddy # layout the stuff grid = MyGrid(self) ### Parameters grid.titleAdd("Verification parameters", False) # Bound on the number of runs self.maxruns = int(Preference.get('maxruns', '5')) txt = wx.StaticText(self, -1, "Maximum number of runs\n(0 disables bound)") ctrl = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) ctrl.SetRange(0, 100) ctrl.SetValue(self.maxruns) self.Bind(wx.EVT_SPINCTRL, self.EvtRuns, ctrl) grid.stepAdd(ctrl, txt) # Matchin options self.match = int(Preference.get('match', '0')) claimoptions = [ 'typed matching', 'find basic type flaws', 'find all type flaws' ] r2 = wx.StaticText(self, -1, "Matching type") l2 = self.ch = wx.Choice(self, -1, choices=claimoptions) l2.SetSelection(self.match) self.Bind(wx.EVT_CHOICE, self.EvtMatch, l2) grid.stepAdd(l2, r2) ### MISC expert stuff grid.titleAdd("Advanced parameters") # Continue after finding the first attack self.prune = int(Preference.get('prune', '2')) claimoptions = [ 'Find all attacks', 'Find first attack', 'Find best attack' ] r8 = wx.StaticText(self, -1, "Search pruning") l8 = self.ch = wx.Choice(self, -1, choices=claimoptions) l8.SetSelection(self.prune) self.Bind(wx.EVT_CHOICE, self.EvtPrune, l8) grid.stepAdd(l8, r8) # Bound on the number of patterns self.maxattacks = int(Preference.get('maxattacks', '10')) r9 = wx.StaticText(self, -1, "Maximum number of patterns\nper claim") l9 = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) l9.SetRange(0, 100) l9.SetValue(self.maxattacks) self.Bind(wx.EVT_SPINCTRL, self.EvtMaxAttacks, l9) grid.stepAdd(l9, r9) self.misc = Preference.get('scytheroptions', '') r10 = wx.StaticText(self, -1, "Additional backend parameters") l10 = wx.TextCtrl(self, -1, self.misc, size=(200, -1)) self.Bind(wx.EVT_TEXT, self.EvtMisc, l10) grid.stepAdd(l10, r10) ### Graph output stuff grid.titleAdd("Graph output parameters") # Bound on the number of classes/attacks if sys.platform.startswith("lin"): defsize = 14 else: defsize = 11 self.fontsize = int(Preference.get('fontsize', defsize)) txt = wx.StaticText(self, -1, "Attack graph font size\n(in points)") ctrl = wx.SpinCtrl(self, -1, "", style=wx.RIGHT) ctrl.SetRange(6, 32) ctrl.SetValue(self.fontsize) self.Bind(wx.EVT_SPINCTRL, self.EvtFontsize, ctrl) grid.stepAdd(ctrl, txt) ### Combine grid.lineAdd() self.SetSizer(grid) self.SetAutoLayout(True)