def build(self): # get icon and resource path app_path = Path(__file__).resolve() for tryroot in (str(app_path.parents[1]) + '/share', str(app_path.parents[0]) + '/data'): tryicon = tryroot + '/pixmaps/' + name + '.png' if os.access(tryicon, os.R_OK): self.icon = tryicon self.resource_rootpath = tryroot break else: print('WARNING: Could not find application resource files', file=sys.stderr) # storewin cfg = self.config['settings'] if cfg['storewin'] == '1': coords = cfg['storewindata'].split() if len(coords) == 4: Window.left, Window.top = int(coords[0]), int(coords[1]) Window.size = (int(coords[2]), int(coords[3])) # determine startmodus self.startmodus = cfg['startmodus'] if self.startmodus[:6] == 'hidden': print('[HIDDEN ]') else: SDL_fixed_window_show() Window.raise_window() # wrap close request to handle startmodus Window.bind(on_request_close=self.on_request_close) return screenman
def myclock(self, dt): if self.edit_modus: return # get clipboard data p = Popen(self.scancmd, stdout=PIPE, stderr=PIPE) output, errors = p.communicate() cliptext = output.decode('utf-8') if cliptext == self.prevcliptext: return self.prevcliptext = cliptext #print('cliptext: "{}"'.format(cliptext)) # debug # match & grab clipboard text, see if button needs to be hidden lastmatch = None cnt = 0 for btn in (w for w in w_main.mainbox.children if type(w) is Button): btn.matchobj = re.match(btn.patt, cliptext, flags=self.reflags) if btn.matchobj: hide_widget(btn, False) # show button lastmatch = btn else: hide_widget(btn, True) cnt += 1 w_main.lab_hidden.text = 'Hidden: ' + str(cnt) if lastmatch and self.startmodus == 'hidden_runfirst': self.press_btn_DL(lastmatch) elif lastmatch or cliptext == '!showyourself': SDL_fixed_window_show() Window.raise_window()
def on_start(self): # Pre-run requirement tests if which('xclip'): self.scancmd = ['xclip', '-o'] elif which('xsel'): self.scancmd = ['xsel', '-o'] if not self.scancmd: self.bad_lockdown = 'Please install either "xclip" or "xsel" to use this app' if not which('youtube-dl'): self.bad_lockdown = 'Please install "youtube-dl" ("ffmpeg" is also recommended!)' # See if app can function cfg = self.config['settings'] statuslabel = w_main.statuslabel if self.bad_lockdown: statuslabel.color = col_bad statuslabel.text = self.bad_lockdown # hide mybar Clock.schedule_once(lambda dt: hide_widget(w_main.mybar), 1) # doing this sooner seems defective SDL_fixed_window_show() Window.raise_window() return elif self.firstrun: statuslabel.color = col_good statuslabel.text = 'First time run, welcome! Wrote config {}\n Copy a YouTube video link into the clipboard'.format( self.confpath) self.firstrun = False else: statuslabel.color = col_good statuslabel.text = cfg['welcome_msg'] # Add command buttons from config i = 1 while True: btnN = 'btn' + str(i) newtext = self.config.getdefault('settings', btnN + '_text', '') if not newtext: break btn = self.add_a_new_button(newtext, cfg[btnN + '_patt'], cfg[btnN + '_cmd']) i += 1 # Only show in edit modus hide_widget(w_main.plusbtn) hide_widget(w_main.delarea) # showbar if cfg['showbar'] == '0': Clock.schedule_once(lambda dt: hide_widget(w_main.mybar), 1) # doing this sooner seems defective # evaluate regex flags self.reflags = 0 flagslist = cfg['reflags'].split('|') for flagstr in flagslist: if hasattr(re, flagstr): self.reflags |= getattr(re, flagstr) # Start responsive timer/scanner self.myclock(0) Clock.schedule_interval(self.myclock, float(cfg['scaninterval']))
def manualSelect(self): self.curentFont = (desktop_file_dialogs.Desktop_FileDialog( title="Select File", initial_directory=".", file_groups=[ desktop_file_dialogs.FileGroup(name="Font files", extensions=["ttf"]), desktop_file_dialogs.FileGroup.All_FileTypes, ], ).show()) Window.raise_window() if self.curentFont: # print(self.root.ids) self.openfont(self.curentFont) self.root.ids.fontexplorer.explore_font(self.curentFont) self.root.ids.scrennm.current = "fontexplorer"
def show_window(self): """Bring minimized and/or hidden App window to the forefront.""" Window.show() Window.raise_window()
def _on_file_drop(self, window, file_path): Window.raise_window() self.openfont(file_path.decode("utf-8"))
def force_window_focus(*args, **kwargs): Window.raise_window()
def StopTimer(self, accurateTime=None): self.StopTimerManually() #Window.minimize() #Window.restore() Window.raise_window()