def beforegui(win): import Preference from modules import Globals win.pref = Preference.Preference() win.pref.load() win.pref.printValues() Globals.pref = win.pref
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 __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 createPreference(self, id, ta_id, course_id, rank): pref = p.Preference(id, ta_id, course_id, rank) self.preferences.append(pref)
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 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 show_preferences(self,*arguments): """Show Preference windows""" print path self.pref = Preference.Preference(self.applet, path)
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)