|
58 | 58 | # System |
59 | 59 | from io import BytesIO |
60 | 60 | from subprocess import Popen, PIPE |
| 61 | +from pathlib import Path |
61 | 62 | import os |
62 | 63 | import sys |
63 | 64 | import shutil |
64 | 65 |
|
65 | 66 | name = 'labelpush' |
66 | | -version = '2018.11.26' |
67 | | -def_iconfiles = [ |
68 | | - os.path.join(sys.prefix, 'local/share/pixmaps/labelpush.png'), |
69 | | - os.path.join(sys.prefix, 'share/pixmaps/labelpush.png'), |
70 | | - 'data/labelpush.png', |
71 | | - 'labelpush.png', |
72 | | -] |
| 67 | +version = '2018.11.27' |
73 | 68 | def_defaultcfg = { |
74 | 69 | 'lpname': 'default', # printer name |
75 | 70 | 'labw': 637, # labelwidth |
@@ -319,6 +314,7 @@ def clock_thread(self): |
319 | 314 | # Thread(target=self.clock_thread).start() |
320 | 315 |
|
321 | 316 | class LabelPushApp(App): |
| 317 | + resource_rootpath = '' |
322 | 318 | def populate_printers(self): |
323 | 319 | # check if lp/cups is found |
324 | 320 | if shutil.which('lp') is None or shutil.which('lpstat') is None: |
@@ -439,13 +435,15 @@ def on_start(self): |
439 | 435 | def on_stop(self): |
440 | 436 | GLO.stop.set() # stop thread so that the program can exit |
441 | 437 | def build(self): |
442 | | - for iconfile in def_iconfiles: |
443 | | - if os.access(iconfile, os.R_OK): |
444 | | - print(':: found app icon ' + iconfile) |
445 | | - self.icon = iconfile |
| 438 | + app_path = Path(__file__).resolve() |
| 439 | + for tryroot in (str(app_path.parents[1]) + '/share', str(app_path.parents[0]) + '/data'): |
| 440 | + tryicon = tryroot + '/pixmaps/' + name + '.png' |
| 441 | + if os.access(tryicon, os.R_OK): |
| 442 | + self.icon = tryicon |
| 443 | + self.resource_rootpath = tryroot |
446 | 444 | break |
447 | | - if not self.icon: |
448 | | - print('WARNING: Could not find application icon', file=sys.stderr) |
| 445 | + else: |
| 446 | + print('WARNING: Could not find application resource files', file=sys.stderr) |
449 | 447 | return RootWidget() |
450 | 448 |
|
451 | 449 | # |
|
0 commit comments