def __init__(self, parent, title, content, mtype): SugarAlert.__init__(self) self._parent = parent if mtype == gtk.MESSAGE_INFO: icon = Icon(icon_name='emblem-notification') icon.show() self.props.icon = icon icon.props.pixel_size = style.SMALL_ICON_SIZE * 2 self.props.title = title self.props.msg = content ok_icon = Icon(icon_name='dialog-ok') self.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) ok_icon.show() self.connect('response', self.remove_myself)
def window_init(self): self.root.title('消费明细记录') with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) self.root.iconbitmap('tmp.ico') os.remove('tmp.ico') # self.root.iconbitmap(r'.\\icon.ico') self.root.geometry('800x530+260+60') self.root.resizable(0, 0) self.cost_time = tkinter.Variable() self.cost_num = tkinter.Variable() self.balance_num = tkinter.Variable() self.remarks = tkinter.Variable() self.first_time = tkinter.Variable() self.last_time = tkinter.Variable() self.select_infor = tkinter.Variable() self.frame_window = tkinter.Frame(self.root) self.window_insert() self.window_select() self.meun_bar() self.frame_window.pack(fill=tkinter.BOTH, anchor='center') self.myfunction = my_function(self.top_information, self.cost_time, self.cost_num, self.bala_entry, self.remarks, self.first_time, self.last_time, self.select_infor, self.tree) # print(self.cost_time) # print(self.cost_num) # print(self.remarks) self.myfunction.init(db)
def adb_mode_switch(self): self.objects = Load_Objects("wave") self.icon = Icon(f'{self.name}.png', uData.setting['confidence']) if not self.auto: for c in self.__chara_list: self.characters[c].adb_mode_switch() for orb in self.orbs: orb.adb_mode_switch()
def version_check(): try: hdk_id=9 wb = load_workbook("\\\\tpfs05\\DATA\\RD2\\30_Personal Data\\Steven.Jian\\HDK_VER.xlsx") ws = wb.active # Must make it active for the rest of operations row_count = ws.max_row latest_hdk =ws.cell(row_count, 2).value hdk_idnew=int(ws.cell(row_count,1).value) wb.close() if hdk_idnew != hdk_id: #print(hdk_idnew) #print(hdk_id) root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("Info","New HDK available! \n Please download it and use the latest bom_tool") try: dirname = filedialog.asksaveasfilename(filetypes=[("HDK","*.zip")],title="Save the new HDK as...",initialfile=latest_hdk) shutil.copy('\\\\tpfs05\\DATA\\RD2\\30_Personal Data\\Steven.Jian\\'+latest_hdk,str(dirname)) print("HDK download success") except OSError: root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("Info", "Download Canceled") #win32api.ShellExecute(0, 'open', '\\\\tpfs05\\DATA\\RD2\\30_Personal Data\\Steven.Jian\\'+latest_hdk, '', '', 1) except OSError: root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("Offline Mode","Please login to azwave.com for HDK version check")
def __init__(self, parent, title, content, icon, timeout): SugarNotify.__init__(self, timeout) self._parent = parent self.props.title = title self.props.msg = content if icon is not None: icon = Icon(icon_name=icon) icon.show() self.props.icon = icon icon.props.pixel_size = style.SMALL_ICON_SIZE * 2 self.connect('response', self.remove_myself)
def project_sync(ws,Path,row_count,username_formating): dest_path1="\\\\tpfs05\\DATA\\RD2\\02_Design Document" dest_path2 ="\\\\tpfs05\\DATA\\RD2\\04_FAE Document" i = 2 while i<=row_count: project_rd = ws.cell(i, 12).value project_rd_formating = str.upper(project_rd).replace(".", "").replace(" ", "") if (project_rd_formating) != (username_formating): root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("ID Verification Error","Only '" + ws.cell(i,1).value + "' project owners are allowed for this operation") elif (project_rd_formating) == (username_formating): try: ############## For 02_Design Document distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Schematic",dest_path1+"\\" + ws.cell(i, 1).value + "\\Schematic",update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Layout", dest_path1+ "\\" + ws.cell(i, 1).value + "\\Layout", update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Test Report", dest_path1+ "\\" + ws.cell(i, 1).value + "\\Test Report", update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\For Customers"+"\\Design Package",dest_path1 + "\\" + ws.cell(i, 1).value + "\\Design Package", update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Software"+"\\nvram",dest_path1 + "\\" + ws.cell(i, 1).value + "\\nvram", update=1) ############## For 04_FAE Document distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Test Report", dest_path2+ "\\" + ws.cell(i, 1).value + "\\Test Report", update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\For Customers"+"\\Design Package",dest_path2 + "\\" + ws.cell(i, 1).value + "\\Design Package", update=1) distutils.dir_util.copy_tree(Path + "\\" + ws.cell(i, 1).value + "\\Software"+"\\nvram",dest_path2 + "\\" + ws.cell(i, 1).value + "\\nvram", update=1) print("Project '" + ws.cell(i,1).value + "' Sync Success!") except distutils.errors.DistutilsFileError: root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("No Such Folder","Folder missing in project '" + ws.cell(i,1).value + "'") i = i + 1
def __init__(self, url, node=None, parent=None, dump=''): self.__parent = parent self.__services = {} self.__devices = {} self.__icons = {} icons = node.find('iconList') if icons is None: icons = [] services = node.find('serviceList') if services is None: services = [] devices = node.find('deviceList') if devices is None: devices = [] self.__node = node for icon in icons: icon = Icon(self, url, icon) self.__icons[icon.__name__] = icon for service in services: scpdurl = service.find('SCPDURL').text.replace(url, '') control_url = service.find('controlURL').text.replace(url, '') service_id = service.find('serviceId').text service_type = service.find('serviceType').text service = Service( self, url, scpdurl, service_type, control_url, dump=dump ) name = service_id.split(':')[-1] service.__name__ = name self.__services[name] = service for device in devices: device = EmbeddedDevice( url, node=device, parent=self, dump=dump ) self.__devices[device.__name__] = device self.url = url self.__name__ = self.friendly_name.replace(' ', '_').replace('-', '')
def __init__(self, url, orig_url): self.orig_url = orig_url self.url_to_search = url self.found = False icons = self.find_icons_at_url() icon = self.get_largest_icon_from_list(icons) if self.found: icon = Icon(icon, orig_url) self.found = icon.valid self.icon = icon
def load_coordinates(size): with open('coordinate.yml', 'r') as stream: coordinate = yaml.safe_load(stream) coordinate = coordinate[size] # areas coords.top_window = coordinate['top_window'] coords.mid_window = coordinate['mid_window'] coords.bot_window = coordinate['bot_window'] coords.troop_info_area = coordinate['troop_info_area'] coords.super_mine_coord_locations = coordinate[ 'super_mine_coord_locations'] coords.tribute_countdown_box = coordinate['tribute_countdown_box'] # icons coords.back = Icon(coordinate['back'][0], img_path(coordinate['back'][1])) coords.castle = Icon(coordinate['castle'][0], img_path(coordinate['castle'][1])) coords.kingdom = Icon(coordinate['kingdom'][0], img_path(coordinate['kingdom'][1])) coords.ally_help = Icon(coordinate['ally_help'][0], img_path(coordinate['ally_help'][1])) coords.gather = Icon(coordinate['gather'][0], img_path(coordinate['gather'][1])) coords.train = Icon(coordinate['train'][0], img_path(coordinate['train'][1])) # coordinate coords.screen_center = coordinate['screen_center'] coords.msg_confirm = coordinate['msg_confirm'] coords.empty_space = coordinate['empty_space'] coords.alliance = coordinate['alliance'] coords.donation = coordinate['donation'] coords.alliance_gift = coordinate['alliance_gift'] coords.gift_collect = coordinate['gift_collect'] coords.donation_res = coordinate['donation_res'] coords.donation_dev = coordinate['donation_dev'] coords.donation_war = coordinate['donation_war'] coords.donation_item = coordinate['donation_item'] coords.donation_1click = coordinate['donation_1click'] coords.donation_confirm = coordinate['donation_confirm'] coords.territory = coordinate['territory'] coords.super_mine = coordinate['super_mine'] coords.half_troop = coordinate['half_troop'] coords.slot_preferred = coordinate['slot_preferred'] coords.ordinary_slot = coordinate['ordinary_slot'] coords.superior_slot = coordinate['superior_slot'] coords.march = coordinate['march'] coords.magnifier = coordinate['magnifier'] coords.search = coordinate['search'] coords.farm = coordinate['farm'] coords.sawmill = coordinate['sawmill'] coords.iron_mine = coordinate['iron_mine'] coords.silver_mine = coordinate['silver_mine'] coords.res_lvl_up = coordinate['res_lvl_up'] coords.res_lvl_dn = coordinate['res_lvl_dn'] # islands coords.resource_islands = coordinate['resource_islands'] coords.tribute_islands = coordinate['tribute_islands'] coords.wall_repair_islands = coordinate['wall_repair_islands']
def get_icon(font, colour, character, size=None): """Redirect to static icon path, creating it first if necessary. :param font: ID of the font, e.g. ``fontawesome`` :param colour: CSS colour without preceding ``#``, e.g. ``000`` or ``eeeeee`` :param character: Name of the character, e.g. ``youtube`` :param size: Size of the icon in pixels """ # Normalise arguments to minimise number of cached images colour = colour.lower() font = font.lower() character = character.lower() # Set size to default if size is disabled in API if size is None or not config.API_ALLOW_SIZE: size = config.SIZE else: if size.lower().endswith('.png'): size = size[:-4] try: size = int(size) except ValueError as err: return error_text('invalid size : {}'.format(size), 400) if not css_colour(colour): return error_text('invalid colour: {}'.format(colour), 400) if len(colour) == 3: # Expand to full 6 characters r, g, b = colour colour = '{r}{r}{g}{g}{b}{b}'.format(r=r, g=g, b=b) if font not in fonts.FONTS: return error_text('unknown font: {}'.format(font), 404) if character.lower().endswith('.png'): character = character[:-4] if character not in fonts.FONTS[font]['characters']: return error_text('unknown character: {}'.format(character), 404) try: icon = Icon(font, colour, character, size) return redirect(icon.url) except ValueError as err: if 'color' in err.message: return error_text('invalid colour: {}'.format(colour), 400) # Re-raise error raise err
def __load_icons(self) -> Dict: images = [ 'kirara_face.png', 'kuromon.png', 'ok.png', 'hai.png', 'tojiru.png', 'friend_icon.png', 'visit_room.png', 'cork_face.png', 'crea_comm_done.png' ] if self.stamina['use']: images += ['stamina_title.png'] if self.loop_count > 0: images += ['again.png'] if self.crea_craft_stop: images += ['crea_craft_occur.png'] if self.data['crash_detection'] and not self.data['adb']['use']: images += ['kirafan_app_icon.png', 'start_screen.png'] icons = [Icon(image, self.data['confidence']) for image in images] return {icon.name: icon for icon in icons}
def __init__(self, root): self.plyNoLst = [] self.download_path = os.path.join(os.path.expanduser('~'), 'Desktop', '电子保单-{}'.format(datetime.now().strftime('%Y%m%d'))).replace('\\', '/') root.title('电子保单下载') # 读取 icon.py 中的图标文件 with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') screenWidth = root.winfo_screenwidth() # 获取显示区域的宽度 screenHeight = root.winfo_screenheight() # 获取显示区域的高度 width, height = 381, 592 left = int((screenWidth - width) / 2) top = int((screenHeight - height) / 2) - 50 root.geometry('{width}x{height}+{left}+{top}'.format(width=width, height=height, left=left, top=top)) root.resizable(0, 0) # 设置窗口宽高固定 self.input_plyNo(root) self.set_download_path(root) self.download_config(root) self.log_frame(root)
def fix_ip_window(self): fix_ip = tkinter.Toplevel() fix_ip.title('数据库IP修改') fix_ip.geometry('300x200+400+200') with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) fix_ip.iconbitmap('tmp.ico') os.remove('tmp.ico') # fix_ip.iconbitmap(r'.\\icon.ico') fix_ip.resizable(0, 0) new_ip = tkinter.Variable() label1 = tkinter.Label( fix_ip, text=' ', height=2, ) label1.pack() balance = ttk.Entry( fix_ip, font=('黑体', 15), width=20, textvariable=new_ip, ) balance.pack() label2 = tkinter.Label( fix_ip, text=' ', height=2, ) label2.pack() button = ttk.Button( fix_ip, text='确认修改', command=lambda: self.my_function.fix_ip(new_ip.get()), # font=('黑体', 15), # justify='center', ) button.pack() fix_ip.mainloop()
def __init__(self): self.dirpath = '' # 文件夹路径 self.savepath = '' # 转换后的文件保存路径 self.showinfo = False # 是否打开信息显示窗口 # 获得当前文件绝对路径 # 使用os.getcwd() 创建快捷方式时 位置会发生变动 # self.curworkpath = os.getcwd() self.curworkpath = os.path.dirname(os.path.abspath(sys.argv[0])) self.win = Tk() self.win.title('pyd打包助手') self.win.resizable(False, False) with open('tmp.ico','wb') as tmp: tmp.write(base64.b64decode(Icon().img)) self.win.iconbitmap('tmp.ico') os.remove('tmp.ico') self.win.attributes('-topmost', True) # 偏移坐标值 self.xpos = self.win.winfo_x() # 软件距离窗口X坐标 self.ypos = self.win.winfo_y() # 软件距离窗口Y坐标 self.winwidth = self.win.winfo_reqwidth() # 当前软件宽 self.winheight = self.win.winfo_reqheight() # 当前软件高 # 绑定窗口移动事件 每次移动更新偏移坐标值 self.win.bind('<Configure>', self._movewindow) # 页面初始化 self.create_widget() # 创建信息显示面板 self.create_infoplan()
def __init__(self, id_: int, total: int): _wave = uData.setting['wave'] self.id = id_ self.ch_id = 'right' self.__chara_list = ['left', 'middle', 'right'] self.total = total self.__myTurn_count = 0 self.auto = _wave[str(self.id)]['auto'] self.name = f'wave_{self.id}-{self.total}' self.objects = Load_Objects("wave") self.icon = Icon(f'{self.name}.png', uData.setting['confidence']) if not self.auto: self.characters = { c: Character(c, self.id) for c in self.__chara_list } self.chars_sp_order = self.__sp_order_init( ) if 'sp_weight_enable' in _wave[str(self.id)] and _wave[str( self.id)]['sp_weight_enable'] else [] # noqa: E501 self.orbs = self.__orb_init() self.__friend = uData.setting['friend_support'] if uData.setting[ 'friend_support'] and uData.setting['friend_support'][ 'wave_N'] == self.id else None # noqa: E501 self.__auto_button_multi_check = 0
#!/usr/bin/python import gtk import gobject import pynotify from icon import Icon from notify import notify from reader import reader def main(): gtk.gdk.threads_enter() reader.start() gtk.main() gtk.gdk.threads_leave() if __name__ == '__main__': gobject.threads_init() if not pynotify.init("Basics"): sys.exit(1) Icon() main()
Button((265, 60, 50, 50), bg='right-50', cb=settingCallback, value=4), Button((5, 115, 50, 50), bg='left-50', cb=settingCallback, value=5), Button((265, 115, 50, 50), bg='right-50', cb=settingCallback, value=6), Button((5, 185, 116, 50), bg='cancel-50', cb=settingCallback, value=7), Button((199, 185, 116, 50), bg='ok-50', cb=settingCallback, value=8), ] ] iconPath = path + '/icons' # Subdirectory containing UI bitmaps (PNG format) print "Loading Icons..." # Load all icons at startup. for file in os.listdir(iconPath): if fnmatch.fnmatch(file, '*.png'): #print file icons.append(Icon(iconPath, file.split('.')[0])) # Assign Icons to Buttons, now that they're loaded print "Assigning Buttons" for s in buttons: # For each screenful of buttons... for b in s: # For each button on screen... for i in icons: # For each icon... if b.bg == i.name: # Compare names; match? b.iconBg = i # Assign Icon to Button b.bg = None # Name no longer used; allow garbage collection if b.fg == i.name: b.iconFg = i b.fg = None # set up the fonts fontpath = pygame.font.match_font('dejavusansmono') zfontpath = path + '/fonts/HandelGotD.ttf'
def __init__(self): self.mu_params, self.mu_cfg = None, None self.app = Tk() #隐藏窗口,防止窗口左上角闪烁一下 self.app.withdraw() self.app.update() #label 文本:textvariable global TX TX = StringVar() #标题 self.app.title('mucopy') #图标直接加载 # self.app.iconbitmap('icon.ico') #图标转为base64 with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) self.app.iconbitmap('tmp.ico') os.remove('tmp.ico') #透明度,不透明 self.app.attributes('-alpha', 1) #去除标题栏 self.app.overrideredirect(True) # self.app.overrideredirect(False) #初始化坐标 self.app.geometry('+200+100') #界面不可缩放 self.app.resizable(0, 0) #置顶 self.app.attributes('-topmost', True) #label self.label self.label = Label(self.app, textvariable=TX, fg='blue', bg='white', relief='flat', wraplength=360, justify='left', anchor='w', height=4, width=48, borderwidth=0, font=('simsun', 12, 'bold')) self.label.grid(row=1, column=0, sticky=N + S + E + W) #text self.text self.text = Text(self.app, fg='red', bg='white', relief='flat', highlightthickness=0, height=24, width=49, borderwidth=0, font=('simsun', 12, 'bold')) self.text.grid(row=2, column=0, sticky=N + S + E + W) #透光设置,自动识别posix、nt if os.name == 'posix': self.app.wm_attributes('-transparent', True) self.app['bg'] = 'systemTransparent' self.label['bg'] = 'systemTransparent' self.text['bg'] = 'systemTransparent' else: self.app.wm_attributes('-transparentcolor', 'white') self.app['bg'] = 'white' #还原窗口 self.app.deiconify() #执行check,返回布尔值,if True,执行主函数,完成后关闭程序 if self.check(): self.start() self.close() self.app.mainloop()
def __init__( self, parent, url, location, service, control_url, node=None, dump='' ): self.__parent = parent self.state_variables = {} self.__actions = {} self.__node = node self.url = url self.__icons = {} if node is not None: icons = node.find('iconList') if icons is None: icons = [] for icon in icons: icon = Icon(self, url, icon) self.__icons[icon.__name__] = icon self.service = service location = location.replace(url, '') location = location.replace('//', '/') if not location.startswith('/'): location = '/' + location response = requests.get(url + location) if dump: path = location if path.startswith('/'): path = path[1:] if '/' in path: path, file_name = path.rsplit('/', 1) path = os.path.join(dump, path) else: file_name = path path = dump if not os.path.exists(path): os.makedirs(path) if not file_name.endswith('.xml'): file_name += '.xml' if isinstance(response.content, bytes): content = response.content.decode('utf-8') else: content = response.content with open(os.path.join(path, file_name), 'w') as f: f.write(content) try: root = etree.fromstring(response.content) except: import traceback print(repr(response.content)) traceback.print_exc() return root = strip_xmlns(root) actions = root.find('actionList') if actions is None: actions = [] state_variables = root.find('serviceStateTable') if state_variables is None: state_variables = [] for state_variable in state_variables: state_variable = StateVariable(state_variable) self.state_variables[state_variable.name] = state_variable for action in actions: action = Action( self, action, self.state_variables, service, url + control_url ) self.__actions[action.__name__] = action
def __init__(self, app): """ main UI for DuplicateShotAssets """ QtGui.QWidget.__init__(self) self.app = app self.charMaxChars = 0 self.propMaxChars = 0 ## To get the step context = self.app.context debug(self.app, method='MainUI', message='Context Step: %s' % context.step['name'], verbose=False) self.chars = [] self.props = [] ## Now build the UI self.mainLayout = QtGui.QHBoxLayout(self) debug(self.app, method='MainUI', message='self.mainLayout built...', verbose=False) ############### ## CHARS LAYOUT self.charParent = QtGui.QGroupBox(self) self.charParent.setTitle('CHARS:') #self.charParent.setMinimumWidth(600) self.charParentLayout = QtGui.QVBoxLayout(self.charParent) self.charScrollLayout = QtGui.QScrollArea(self) debug(self.app, method='MainUI', message='self.charScrollLayout built...', verbose=False) self.charGroupBox = QtGui.QGroupBox(self.charScrollLayout) self.charGroupBox.setFlat(True) self.charScrollLayout.setWidget(self.charGroupBox) self.charScrollLayout.setWidgetResizable(True) debug(self.app, method='MainUI', message='self.charGroupBox built...', verbose=False) self.charLayout = QtGui.QVBoxLayout(self.charGroupBox) debug(self.app, method='MainUI', message='self.charLayout built...', verbose=False) ############### ## PROPS LAYOUT self.propParent = QtGui.QGroupBox(self) self.propParent.setTitle('PROPS:') #self.propParent.setMinimumWidth(600) self.propParentLayout = QtGui.QVBoxLayout(self.propParent) self.propScrollLayout = QtGui.QScrollArea(self) debug(self.app, method='MainUI', message='self.propScrollLayout built...', verbose=False) self.propsGroupBox = QtGui.QGroupBox(self.propScrollLayout) self.propsGroupBox.setFlat(True) self.propScrollLayout.setWidget(self.propsGroupBox) self.propScrollLayout.setWidgetResizable(True) debug(self.app, method='MainUI', message='self.propsGroupBox built...', verbose=False) self.propsLayout = QtGui.QVBoxLayout(self.propsGroupBox) debug(self.app, method='MainUI', message='self.propsLayout built...', verbose=False) #################### ## The Button layout self.buttonLayout = QtGui.QVBoxLayout(self) ## The buttons ## The duplicate button self.duplicateButton = QtGui.QPushButton(Icon('plus.png'), 'Duplicate Assets', self) self.duplicateButton.clicked.connect(self._duplicateAssets) ## Add buttons to layout self.buttonLayout.addWidget(self.duplicateButton) self.buttonLayout.addStretch(1) self.charParentLayout.addWidget(self.charScrollLayout) self.propParentLayout.addWidget(self.propScrollLayout) ## Now do the final layout bits self.mainLayout.addWidget(self.charParent) self.mainLayout.addWidget(self.propParent) self.mainLayout.addLayout(self.buttonLayout) debug(self.app, method='MainUI', message='self.mainLayout addWidgets success...', verbose=False) self._popChars() debug(self.app, method='MainUI', message='self._popChars()...', verbose=False) self._popProps() debug(self.app, method='MainUI', message='self._popProps()...', verbose=False) if not self.props: self.propScrollLayout.hide() if not self.chars: self.charScrollLayout.hide() self.charGroupBox.resize(self.charGroupBox.sizeHint()) self.propsGroupBox.resize(self.propsGroupBox.sizeHint()) debug(self.app, method='MainUI', message='self.charMaxChars: %s' % self.charMaxChars, verbose=False) self.charParent.setMinimumWidth(self.charMaxChars + 500) self.propParent.setMinimumWidth(self.propMaxChars + 500) self.resize(self.sizeHint())
self.Line3, text="文件输出路径", command=lambda: browse_output_button(self.FileOutputVar)) self.buttonfileOutput.pack(side=LEFT, fill=X, expand=YES, anchor=W, padx=1, pady=1) self.buttonfileMerge = Button( self.Line4, text="合并", command=lambda: file_merge(self.File1Var.get(), self.File2Var.get( ), self.FileOutputVar.get())) self.buttonfileMerge.pack(side=LEFT, fill=X, expand=YES, anchor=W, padx=1, pady=1) if __name__ == '__main__': mainwindow = window() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) tmp.close() mainwindow.iconbitmap('tmp.ico') os.remove('tmp.ico') mainwindow.mainloop()
def add_icon(self, filename): """ See animations/README.md for details """ icon = Icon(filename) self.icons.append(icon)
def __init__(self, app): QtGui.QWidget.__init__(self) self.app = app debug(app=self.app, method='MainUI', message='MainUI initialized...', verbose=False) #self.tk = sgtk.sgtk_from_path("T:/software/bubblebathbay") self.mainLayout = QtGui.QVBoxLayout(self) debug(app=self.app, method='MainUI', message='mainLayout built...', verbose=False) ## Buttons self.buttonsGroupBox = QtGui.QGroupBox(self) self.buttonsGroupBox.setTitle('MDL/SRF:') debug(app=self.app, method='MainUI', message='self.optionsGroupBox built...', verbose=False) self.optionsLayout = QtGui.QGridLayout(self.buttonsGroupBox) debug(app=self.app, method='MainUI', message='self.optionsLayout built...', verbose=False) self.groupPaintedButton = QtGui.QPushButton('Cleanup Painted Archives') self.groupPaintedButton.released.connect(self.cleanUpPaintedArchives) self.groupPaintedButton.setToolTip( 'This is used to clean up your scene after doing a paint of the core_archives' ) self.cleanDeadCAButton = QtGui.QPushButton('Remove Dead Core Archives') self.cleanDeadCAButton.released.connect( coreLib.cleanupDeadCoreArchives) self.cleanDeadCAButton.setToolTip( 'Used to clean out any old core_archives.\nNOTE: If you have old namspaces left over newly imported core_archives\nwill have bad names so manually cleanup any left over namespaces!' ) self.removeAllNSButton = QtGui.QPushButton(Icon('skull.png'), 'Remove ALL Namespaces', self) self.removeAllNSButton.released.connect(cleanup.removeAllNS) self.removeAllNSButton.setToolTip( 'Cleans ALL namespaces from scene.\nDO NOT USE if you have active core archives in the scene you want to keep!\nUse ONLY on a full scene cleanup!' ) self.removeAllNSButton.setStyleSheet( "QPushButton {text-align: center; background: dark red}") self.prepPublishButton = QtGui.QPushButton('Prep for Publish') self.prepPublishButton.released.connect(self.prepForPublish) self.prepPublishButton.setToolTip( 'This can be used to clean a scenes archives prep for publish pre a full rebuild' ) ## THE PREVIEW STUFF GIN DID self.corePreviewSetupButton = QtGui.QPushButton('corePreviewSetup') self.corePreviewSetupButton.released.connect(coreLib.corePreviewSetup) self.corePreviewSetupButton.setToolTip( 'This can be used to preview your full res core archives') self.previewOnButton = QtGui.QPushButton( 'Turn Vis on For CArch Preview Meshes') self.previewOnButton.released.connect( partial(coreLib.cPreview_visibility, True)) self.previewOnButton.setToolTip( 'Turn on the vis for the high res preview meshes') self.previewOffButton = QtGui.QPushButton( 'Turn Vis Off For CArch Preview Meshes') self.previewOffButton.released.connect( partial(coreLib.cPreview_visibility, False)) self.previewOffButton.setToolTip( 'Turn off the vis for the high res preview meshes') self.coresOnButton = QtGui.QPushButton('Turn Vis on For CArchs') self.coresOnButton.released.connect( partial(coreLib.cArch_visibility, True)) self.coresOnButton.setToolTip('Turn on the vis for the core archives') self.coresOffButton = QtGui.QPushButton('Turn Vis Off For CArchs') self.coresOffButton.released.connect( partial(coreLib.cArch_visibility, False)) self.coresOffButton.setToolTip( 'Turn off the vis for the core archives') self.deletePreviewButton = QtGui.QPushButton( Icon('skull.png'), 'Remove CArch Preview Meshes', self) self.deletePreviewButton.released.connect( coreLib.deleteCorePreviewSetup) self.deletePreviewButton.setToolTip( 'Remove all high res preview meshes') self.deletePreviewButton.setStyleSheet( "QPushButton {text-align: center; background: dark red}") self.optionsLayout.addWidget(self.groupPaintedButton, 0, 0) self.optionsLayout.addWidget(self.cleanDeadCAButton, 0, 1) self.optionsLayout.addWidget(self.removeAllNSButton, 0, 2) self.optionsLayout.addWidget(self.prepPublishButton, 0, 3) self.optionsLayout.addWidget(self.corePreviewSetupButton, 1, 0) self.optionsLayout.addWidget(self.previewOnButton, 1, 1) self.optionsLayout.addWidget(self.previewOffButton, 1, 2) self.optionsLayout.addWidget(self.coresOnButton, 1, 3) self.optionsLayout.addWidget(self.coresOffButton, 1, 4) self.optionsLayout.addWidget(self.deletePreviewButton, 1, 5) self.lightingGroupBox = QtGui.QGroupBox(self) self.lightingGroupBox.setTitle('MDL/SRF/LIGHT:') self.lightingLayout = QtGui.QVBoxLayout(self.lightingGroupBox) ## The big bad rebuild all button self.rebuildAllButton = QtGui.QPushButton( 'Full Scene Rebuild of Core archives') self.rebuildAllButton.released.connect(self.rebuildArchives) self.rebuildAllButton.setToolTip( 'Use this to cleanup all the duplicated archives with a full rebuild of the scene.' ) self.lightingLayout.addWidget(self.rebuildAllButton) ## Delete Core Archive button self.removeCAButton = QtGui.QPushButton( 'Full cleanup of Core Archive!') self.removeCAButton.released.connect(self.removeCoreArchiveSetup) self.removeCAButton.setToolTip( 'Use this to remove all the core archive related stuffs.') self.removeCAButton.setStyleSheet( "QPushButton {text-align: center; background: dark red}") self.lightingLayout.addWidget(self.removeCAButton) self.mainLayout.addWidget(self.buttonsGroupBox) self.mainLayout.addWidget(self.lightingGroupBox) self.resize(self.sizeHint())
def attachIcon(self, settings): icon = Icon(settings) self.icons.append(icon) return icon
def main(): try: username=getpass.getuser().upper() print("User ID:"+username) #print(str.upper(username).replace(".","").replace(" ","")) username_formating=str(username).replace(".","").replace(" ","") settings_msg = '' parser = GooeyParser(description=settings_msg) subs = parser.add_subparsers(help='commands', dest='command') bom_parser = subs.add_parser('Project_Sync_Creator', help='Project Sync & Creator is a tool to Sync and Create your project') bom_parser.add_argument('Target_Folder', help='Choose Target_Folder which contain your projects \n (when Sync option is enabled, this become the source folder \n and target is \\\\tpfs05\\DATA\\RD2\\02_Design Document) and \\\\tpfs05\\DATA\\RD2\\02_Design Document)', type=str, widget='DirChooser') #bom_parser.add_argument('--Project_List', type=argparse.FileType, # help='Write the protocol headers to the specified file') bom_parser.add_argument('Project_List', help='Choose HW Project List \n (Please download it from RD2 website)', type=str, widget='FileChooser') bom_parser.add_argument("--Sync", action="store_true", help='When Enabled,Target Folder Became Source Folder \n All Folders in Project list will be updated to tpfs05 network drive') t_dataproc = time.clock() args = parser.parse_args() Path = args.Target_Folder P_list=args.Project_List #print(Path) #print(P_list) wb = load_workbook(P_list,data_only=True) ws = wb.active # Must make it active for the rest of operations Base_filename = os.path.basename(P_list) if ((ws['A1'].value) != "Project"): root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("Format error", "Please make sure Column A1 in '"+ Base_filename+"' is 'Project'") wb.close() sys.exit() row_count = ws.max_row #print(row_count) i = 2 if args.Sync is not True: while i<=row_count: project_rd = ws.cell(i, 12).value project_rd_formating = str.upper(project_rd).replace(".", "").replace(" ", "") if Path==("\\\\tpfs05\\DATA\\RD2\\02_Design Document") and (project_rd_formating) == (username_formating) : distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Report") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB User Guide") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\nvram") print(ws.cell(i,1).value+" project folder created!") elif Path==("\\\\tpfs05\\DATA\\RD2\\02_Design Document") or Path==("\\\\tpfs05\\DATA\\RD2\\04_FAE Document") and (project_rd_formating) != (username_formating) : root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("ID Verification Error", "Only '"+ws.cell(i,1).value+"' project owners are allowed for this operation") elif Path==("\\\\tpfs05\\DATA\\RD2\\04_FAE Document") and (project_rd_formating) == (username_formating) : distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Design Package\\EVB User Guide") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\nvram") print(ws.cell(i, 1).value + " project folder created!") else: distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Board"+ "\\Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Board" + "\\Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Board" + "\\For MFG") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Board" + "\\Component Docs") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\For Certification") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\For MFG") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Component Docs") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\ISO Docs") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Test Report") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\For Customers"+"\\Design Package\\EVB Schematic") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\For Customers"+"\\Design Package\\EVB Layout") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\For Customers"+"\\Design Package\\EVB User Guide") distutils.dir_util.mkpath(Path + "\\" + ws.cell(i, 1).value + "\\Software"+"\\nvram") print(ws.cell(i, 1).value + " project folder created!") i=i+1 elif args.Sync : project_sync(ws,Path,row_count,username_formating) # New_Path=os.path.split(Path)[0]+"\\" # wb.save(New_Path+Base_filename+"_new.xlsx") # wb.close() # print("DataPROC=" + str(time.clock() - t_dataproc) + "sec") # print("The new xlsx is successfully created") except openpyxl.utils.exceptions.InvalidFileException: root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("File format error", "Please use .xlsx file format") except FileNotFoundError: root = Tk() with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') os.remove('tmp.ico') root.withdraw() tkinter.messagebox.showinfo("File format error", "File not found") wb.close() t_vcheck = time.clock() version_check() print("version_check()=" + str(time.clock() - t_vcheck) + "sec")
def __init__(self, app): """ main UI for STATIC ENV handling I always build my UI in __init__ so suck it up.. """ QtGui.QWidget.__init__(self) self.app = app context = self.app.context self.fileBoxes = [] ## Instance the api for talking directly to shotgun. base_url = "http://bubblebathbay.shotgunstudio.com" script_name = 'audioUploader' api_key = 'bbfc5a7f42364edd915656d7a48d436dc864ae7b48caeb69423a912b930bc76a' self.sgsrv = Shotgun(base_url=base_url, script_name=script_name, api_key=api_key, ensure_ascii=True, connect=True) self.shotNum = self._getShotNum()[0] self.currentENV = self._getShotNum()[1] debug(self.app, method='MainUI', message='self.shotNum: %s' % self.shotNum, verbose=False) debug(self.app, method='MainUI', message='self.currentENV: %s' % self.currentENV, verbose=False) self.lightAlembicFolder = 'I:/lsapipeline/episodes/ep000/%s/Light/publish/alembic_anim' % self.shotNum ## Now build the UI self.mainLayout = QtGui.QHBoxLayout(self) self.leftSideLayout = QtGui.QVBoxLayout(self) debug(self.app, method='MainUI', message='self.mainLayout built...', verbose=False) ########################## ### ENV SELECTION PULLDOWN self.envLayout = QtGui.QVBoxLayout(self) self.envPulldown = QtGui.QComboBox() getENVS = self.sgsrv.find( 'Asset', filters=[["code", "contains", 'ENV_'], ["code", "not_contains", '_ENV_'], ["code", "not_contains", 'WORLDMAP'], ["code", "not_contains", 'TSETbuild']], fields=['code']) debug(self.app, method='MainUI', message='getENVS: %s' % getENVS, verbose=False) if self.shotNum: for each in getENVS: if each['code'] == self.currentENV: self.envPulldown.addItem(each['code']) self.lightAlembicFolder = 'I:/lsapipeline/episodes/ep000/%s/Light/publish/alembic_anim' % self.shotNum self.envPulldown.setCurrentIndex( self.envPulldown.findText(self.currentENV)) debug(self.app, method='MainUI', message='self.envPulldown setCurrentIndex...', verbose=False) else: for each in getENVS: if 'ANIM' in each['code']: self.envPulldown.addItem(each['code']) self.fetchAssetListButton = QtGui.QPushButton(Icon('refresh.png'), 'Fetch Asset List') self.fetchAssetListButton.setStyleSheet( "QPushButton {text-align : left}") self.fetchAssetListButton.released.connect(self._fetchAssetList) debug(self.app, method='MainUI', message='self.fetchAssetListButton built...', verbose=False) self.importAssetButton = QtGui.QPushButton(Icon('alembic.png'), 'Import latest Pub ABC') self.importAssetButton.setStyleSheet("QPushButton {text-align : left}") self.importAssetButton.released.connect(self._fetchMDLAlembicPublish) debug(self.app, method='MainUI', message='self.importAssetButton built...', verbose=False) self.checkMDLButton = QtGui.QPushButton(Icon('refresh.png'), 'Check For RIG Publishes') self.checkMDLButton.setStyleSheet("QPushButton {text-align : left}") self.checkMDLButton.released.connect( self._checkVersionsAgainstPublishes) debug(self.app, method='MainUI', message='self.checkMDLButton built...', verbose=False) self.checkSRFXMLButton = QtGui.QPushButton(Icon('refresh.png'), 'Check For SRF Publishes') self.checkSRFXMLButton.setStyleSheet("QPushButton {text-align : left}") self.checkSRFXMLButton.released.connect( self._checkSRFVersionsAgainstPublishes) self.lambert1Button = QtGui.QPushButton(Icon('refresh.png'), 'Check lambert1 objects') self.lambert1Button.setStyleSheet("QPushButton {text-align : left}") self.lambert1Button.released.connect(self._lambert1Object) self.checkFileInPathButton = QtGui.QPushButton( Icon('refresh.png'), 'Check Invalid FileIn Path') self.checkFileInPathButton.setStyleSheet( "QPushButton {text-align : left}") self.checkFileInPathButton.released.connect(self.checkFileInPath) self.checkNonManifoldButton = QtGui.QPushButton( Icon('refresh.png'), 'Check Non-Manifold Geometry') self.checkNonManifoldButton.setStyleSheet( "QPushButton {text-align : left}") self.checkNonManifoldButton.released.connect( self.cleanupNonManifoldGeometry) if context.step['name'] == 'Anm': self.creaseXMLButton = QtGui.QPushButton('Create crease XML') self.creaseXMLButton.released.connect(self._writeCreaseToXML) self.creaseXMLButton.setEnabled(True) if context.step['name'] == 'Light': self.fetchCreaseXMLButton = QtGui.QPushButton( 'Fetch latest published crease XML') self.fetchCreaseXMLButton.released.connect( partial(self._getCreaseFromXML, rootPrefix='ENV_DOCKS_STATICANIM_ABC_ANIM_CACHES_hrc')) self.fetchCreaseXMLButton.setEnabled(True) self.republishALL = QtGui.QPushButton('Publish ABC from ANM') self.republishALL.released.connect(self._republishAllAlembicsForENV) self.republishALL.setEnabled(True) ## Add stuff to the env layout self.envLayout.addWidget(self.envPulldown) self.envLayout.addWidget(self.fetchAssetListButton) self.envLayout.addWidget(self.importAssetButton) self.envLayout.addWidget(self.checkMDLButton) self.envLayout.addWidget(self.checkSRFXMLButton) self.envLayout.addWidget(self.lambert1Button) self.envLayout.addWidget(self.checkFileInPathButton) self.envLayout.addWidget(self.checkNonManifoldButton) self.envLayout.addWidget(self.republishALL) if context.step['name'] == 'Anm': self.envLayout.addWidget(self.creaseXMLButton) if context.step['name'] == 'Light': self.envLayout.addWidget(self.fetchCreaseXMLButton) ###################### ### ENV RELATED ASSETS self.assetLayout = QtGui.QVBoxLayout(self) ### Now do the check boxes for files.... self.scrollLayout = QtGui.QScrollArea(self) self.scrollLayout.setMinimumHeight(300) self.envAssetsGroupBox = QtGui.QGroupBox(self.scrollLayout) self.envAssetsGroupBox.setFlat(True) self.scrollLayout.setWidget(self.envAssetsGroupBox) self.scrollLayout.setWidgetResizable(True) self.envAssetsLayout = QtGui.QGridLayout(self.envAssetsGroupBox) self.assetLayout.addWidget(self.scrollLayout) self.mainLayout.addLayout(self.leftSideLayout) ## Add stuff to leftSideLayout self.leftSideLayout.addLayout(self.envLayout) self.leftSideLayout.addStretch(1) ## Add anything else to the HBox self.mainLayout.addLayout(self.assetLayout) self.resize(1000, 500) debug(self.app, method='MainUI', message='ui built successfully fetching assets now...', verbose=False) debug(self.app, method='MainUI', message='self.envPulldown.currentText(): %s' % self.envPulldown.currentText(), verbose=False) self._fetchAssetList() self.envPulldown.currentIndexChanged.connect( partial(self._getShotNumFromMenuName)) self.envPulldown.currentIndexChanged.connect( partial(self._fetchAssetList))
def ico_repair(root): with open('tmp.ico', 'wb') as tmp: tmp.write(base64.b64decode(Icon().img)) root.iconbitmap('tmp.ico') return 'tmp.ico'
def __init__(self, app): """ main UI for STATIC ENV handling I always build my UI in __init__ so suck it up.. """ QtGui.QWidget.__init__(self) self.app = app self.fileBoxes = [] ## Instance the api for talking directly to shotgun. base_url = "http://bubblebathbay.shotgunstudio.com" script_name = 'audioUploader' api_key = 'bbfc5a7f42364edd915656d7a48d436dc864ae7b48caeb69423a912b930bc76a' self.sgsrv = Shotgun(base_url = base_url , script_name = script_name, api_key = api_key, ensure_ascii=True, connect=True) self.shotNum = self._getShotNum()[0] self.currentENV = self._getShotNum()[1] debug(self.app, method = 'MainUI', message = 'self.shotNum: %s' % self.shotNum, verbose = False) debug(self.app, method = 'MainUI', message = 'self.currentENV: %s' % self.currentENV, verbose = False) self.lightAlembicFolder = 'I:/lsapipeline/episodes/ep000/%s/Light/publish/alembic_static' % self.shotNum ## Now build the UI self.mainLayout = QtGui.QHBoxLayout(self) self.leftSideLayout = QtGui.QVBoxLayout(self) debug(self.app, method = 'MainUI', message = 'self.mainLayout built...', verbose = False) ########################## ### ENV SELECTION PULLDOWN self.envLayout = QtGui.QVBoxLayout(self) self.envPulldown = QtGui.QComboBox() getENVS = self.sgsrv.find('Asset', filters = [["code", "contains", 'ENV_'], ["code", "not_contains", '_ENV_'], ["code", "not_contains", 'WORLDMAP'], ["code", "not_contains", 'TSETbuild']], fields=['code']) debug(self.app, method = 'MainUI', message = 'getENVS: %s' % getENVS, verbose = False) if self.shotNum: for each in getENVS: if each['code'] == self.currentENV: self.envPulldown.addItem(each['code']) self.lightAlembicFolder = 'I:/lsapipeline/episodes/ep000/%s/Light/publish/alembic_static' % self.shotNum self.envPulldown.setCurrentIndex(self.envPulldown.findText(self.currentENV)) debug(self.app, method = 'MainUI', message = 'self.envPulldown setCurrentIndex...', verbose = False) else: for each in getENVS: if 'STATIC' in each['code']: self.envPulldown.addItem(each['code']) self.fetchAssetListButton = QtGui.QPushButton(Icon('refresh.png'), 'Fetch Asset List') self.fetchAssetListButton.setStyleSheet("QPushButton {text-align : left}") self.fetchAssetListButton.released.connect(self._fetchAssetList) debug(self.app, method = 'MainUI', message = 'self.fetchAssetListButton built...', verbose = False) self.importAssetButton = QtGui.QPushButton(Icon('alembic.png'), 'Import latest Pub ABC for Sel') self.importAssetButton.setStyleSheet("QPushButton {text-align : left}") self.importAssetButton.released.connect(self._fetchMDLAlembicPublish) debug(self.app, method = 'MainUI', message = 'self.importAssetButton built...', verbose = False) self.checkMDLButton = QtGui.QPushButton(Icon('refresh.png'), 'Check For MDL ABC Publishes') self.checkMDLButton.setStyleSheet("QPushButton {text-align : left}") self.checkMDLButton.released.connect(self._checkVersionsAgainstPublishes) debug(self.app, method = 'MainUI', message = 'self.checkMDLButton built...', verbose = False) self.redoSetsButton = QtGui.QPushButton(Icon('plus.png'), 'ReDo Set Assignments') self.redoSetsButton.setStyleSheet("QPushButton {text-align : left}") self.redoSetsButton.released.connect(self._createSets) debug(self.app, method = 'MainUI', message = 'self.redoSetsButton built...', verbose = False) self.checkSRFXMLButton = QtGui.QPushButton(Icon('refresh.png'), 'Check For SRF Publishes') self.checkSRFXMLButton.setStyleSheet("QPushButton {text-align : left}") self.checkSRFXMLButton.released.connect(self._checkSRFVersionsAgainstPublishes) self.cleanDuplicateCoresButton = QtGui.QPushButton(Icon('AssignedFileIt.png'), 'Clean Duplicate Cores') self.cleanDuplicateCoresButton.setStyleSheet("QPushButton {text-align : left}") self.cleanDuplicateCoresButton.released.connect(self._fixTheFuckingCores) self.cleanDuplicateCoresButton.setToolTip('This is performed on every import of an static env via the multiloader.\n Exposed just in case you need to run this manually.\n This will go through a scene with multiple static ENVs in it \nand try to make sure duplicate cores are renering correctly.') self.removeCoreGrpsButton = QtGui.QPushButton(Icon('skull.png'), 'Remove old Core Grps under geo_hrc') self.removeCoreGrpsButton.setStyleSheet("QPushButton {text-align : left}") self.removeCoreGrpsButton.released.connect(self._removeCoreGrps) self.removeCoreGrpsButton.setToolTip('You can use this to clean up any old core grps under the geo_hrc grps in a scene\nafer you have done a core archive rebuild from xml...') ## THIS IS UP TO YOU TO ENABLE. IT SHOULDNT BE REQUIRED AS THE MDL PUBLISH SHOULD NOW BE EXPORTING THE CORRECT ATTRS FOR ALEMBIC self.republishALL = QtGui.QPushButton('Republish ALL MDL Alembics for %s' % self.currentENV) self.republishALL.released.connect(self._republishAllAlembicsForENV) self.republishALL.setEnabled(True) self.lambert1Button = QtGui.QPushButton(Icon('refresh.png'), 'Check lambert1 objects') self.lambert1Button.setStyleSheet("QPushButton {text-align : left}") self.lambert1Button.released.connect(self._lambert1Object) self.caNSclashCheckButton = QtGui.QPushButton(Icon('refresh.png'), 'Check Core Archive Namespace') self.caNSclashCheckButton.setStyleSheet("QPushButton {text-align : left}") self.caNSclashCheckButton.released.connect(self.coreArchiveNSclashCheck) self.checkFileInPathButton = QtGui.QPushButton(Icon('refresh.png'), 'Check Invalid FileIn Path') self.checkFileInPathButton.setStyleSheet("QPushButton {text-align : left}") self.checkFileInPathButton.released.connect(self.checkFileInPath) self.checkNonManifoldButton = QtGui.QPushButton(Icon('refresh.png'), 'Check Non-Manifold Geometry') self.checkNonManifoldButton.setStyleSheet("QPushButton {text-align : left}") self.checkNonManifoldButton.released.connect(self.cleanupNonManifoldGeometry) ## Add stuff to the env layout self.envLayout.addWidget(self.envPulldown) self.envLayout.addWidget(self.fetchAssetListButton) self.envLayout.addWidget(self.importAssetButton) self.envLayout.addWidget(self.checkMDLButton) self.envLayout.addWidget(self.checkSRFXMLButton) self.envLayout.addWidget(self.redoSetsButton) self.envLayout.addWidget(self.cleanDuplicateCoresButton) self.envLayout.addWidget(self.removeCoreGrpsButton) self.envLayout.addWidget(self.republishALL) self.envLayout.addWidget(self.lambert1Button) self.envLayout.addWidget(self.caNSclashCheckButton) self.envLayout.addWidget(self.checkFileInPathButton) self.envLayout.addWidget(self.checkNonManifoldButton) ###################### ### ENV RELATED ASSETS self.assetLayout = QtGui.QVBoxLayout(self) ### Now do the check boxes for files.... self.scrollLayout = QtGui.QScrollArea(self) self.scrollLayout.setMinimumHeight(300) self.envAssetsGroupBox = QtGui.QGroupBox(self.scrollLayout) self.envAssetsGroupBox.setFlat(True) self.scrollLayout.setWidget(self.envAssetsGroupBox) self.scrollLayout.setWidgetResizable(True) self.envAssetsLayout = QtGui.QGridLayout(self.envAssetsGroupBox) self.assetLayout.addWidget(self.scrollLayout) self.mainLayout.addLayout(self.leftSideLayout) ## Add stuff to leftSideLayout self.leftSideLayout.addLayout(self.envLayout) self.leftSideLayout.addStretch(1) ## Add anything else to the HBox self.mainLayout.addLayout(self.assetLayout) self.resize(1000, 500) debug(self.app, method = 'MainUI', message = 'ui built successfully fetching assets now...', verbose = False) debug(self.app, method = 'MainUI', message = 'self.envPulldown.currentText(): %s' % self.envPulldown.currentText(), verbose = False) self._fetchAssetList() self.envPulldown.currentIndexChanged.connect(partial(self._getShotNumFromMenuName)) self.envPulldown.currentIndexChanged.connect(partial(self._fetchAssetList))
from base64 import b64encode with open("icon.py","w") as f: f.write('class Icon(object):\n') f.write('\tdef __init__(self):\n') f.write("\t\tself.img='") with open("icon.ico","rb") as i: b64str = b64encode(i.read()) with open("icon.py","ab+") as f: f.write(b64str) with open("icon.py","a") as f: f.write("'") #Then in main.py from base64 import b64decode from os import remove from icon import Icon with open('tmp.ico', 'wb') as tmp: tmp.write(b64decode(Icon().img)) app.setWindowIcon(QIcon('tmp.ico')) remove('tmp.ico')
def reset(self): """ This method is called before transitioning to this scene. Use it to (re-)initialize any state necessary for your scene. """ self.next_frame_at = 0 self.reset_icon() t = time.time() if t < self.last_refreshed_at + 1800: return # fetch a new forecast from SMHI url = '{}/api/category/pmp3g/version/2/geotype/point/lon/{}/lat/{}/data.json'.format( self.api_url, self.lon, self.lat) print( 'WeatherScene: reset called, requesting weather forecast from: {}'. format(url)) r = requests.get(url, headers=self.headers, stream=True) if r.status_code != 200: print('WeatherScene: failed to request {}: status {}'.format( url, r.status_code)) return print('WeatherScene: parsing weather forecast') next_hour = int(time.time()) next_hour = next_hour - next_hour % 3600 + 3600 expected_timestamp = '{:04d}-{:02d}-{:02d}T{:02d}'.format( *time.gmtime(next_hour)) temp, ws, symb = self.get_forecast(r.raw, expected_timestamp) # Close socket and free up RAM r.close() r = None gc.collect() if temp == None: print( 'WeatherScene: failed to find forecast for timestamp prefix: {}' .format(expected_timestamp)) return self.temperature = float(temp.decode()) self.wind_speed = float(ws.decode()) self.symbol = int(symb.decode()) self.last_refreshed_at = t filename = self.symbol_to_icon[self.symbol] if not filename: return if type(filename) == list: lt = time.localtime(next_hour) if lt[3] < 7 or lt[3] > 21: # Assume night icon filename = filename[0] else: filename = filename[1] if self.icon: # MicroPython does not support destructors so we need to manually # close the file we have opened self.icon.close() # Close icon file self.icon = Icon(self.dir_prefix + filename) self.icon.set_intensity(self.intensity) self.reset_icon()