Check-in [164043075d]
Overview
Comment: | Disable some debugging, move gui_startup() to mygtk collection, allow markup for mygtk.label() text. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
164043075d045815297f334bb2625b89 |
User & Date: | mario on 2015-03-28 07:25:38 |
Other Links: | manifest | tags |
Context
2015-03-28
| ||
07:26 | Implement plugin meta data extraction in config.plugin_meta() instead of channels.__init__ check-in: acaea4439d user: mario tags: trunk | |
07:25 | Disable some debugging, move gui_startup() to mygtk collection, allow markup for mygtk.label() text. check-in: 164043075d user: mario tags: trunk | |
07:24 | Fix dbus ids, add genre to API (needs mapping perhaps), test against example patch. check-in: 61c7ecec61 user: mario tags: trunk | |
Changes
Modified mygtk.py from [2d60af2beb] to [dec662c44d].
1 2 3 4 5 6 | # # encoding: UTF-8 # api: python # type: functions # title: mygtk helper functions # description: simplify usage of some gtk widgets | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # # encoding: UTF-8 # api: python # type: functions # title: mygtk helper functions # description: simplify usage of some gtk widgets # version: 1.8 # author: mario # license: public domain # # # Wrappers around gtk methods. The TreeView method .columns() allows # to fill a treeview. It adds columns and data rows with a mapping # dictionary (which specifies many options and data positions). |
︙ | ︙ | |||
154 155 156 157 158 159 160 | if (not rowmap): for desc in datamap: for var in xrange(2, len(desc)): vartypes.append(desc[var][1]) # content types rowmap.append(desc[var][0]) # dict{} column keys in entries[] list # create gtk array storage ls = gtk.ListStore(*vartypes) # could be a TreeStore, too | | | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | if (not rowmap): for desc in datamap: for var in xrange(2, len(desc)): vartypes.append(desc[var][1]) # content types rowmap.append(desc[var][0]) # dict{} column keys in entries[] list # create gtk array storage ls = gtk.ListStore(*vartypes) # could be a TreeStore, too #__print__(dbg.UI, vartypes, len(vartypes)) #__print__(dbg.DATA, rowmap, len(rowmap)) # prepare for missing values, and special variable types defaults = { str: "", unicode: "", bool: False, int: 0, |
︙ | ︙ | |||
194 195 196 197 198 199 200 | # add ls.append(row) # had to be adapted for real TreeStore (would require additional input for grouping/level/parents) except: # brute-force typecast ls.append( [va if ty==gtk.gdk.Pixbuf else ty(va) for va,ty in zip(row,vartypes)] ) | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | # add ls.append(row) # had to be adapted for real TreeStore (would require additional input for grouping/level/parents) except: # brute-force typecast ls.append( [va if ty==gtk.gdk.Pixbuf else ty(va) for va,ty in zip(row,vartypes)] ) #if entries: #__print__("[37m→[0m", row, len(row)) # apply array to widget widget.set_model(ls) return ls pass |
︙ | ︙ | |||
401 402 403 404 405 406 407 | w.modify_bg(gtk.STATE_NORMAL, c) # return modified or wrapped widget return w # Create GtkLabel @staticmethod | | > > | | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | w.modify_bg(gtk.STATE_NORMAL, c) # return modified or wrapped widget return w # Create GtkLabel @staticmethod def label(text, size=400, markup=0): label = gtk.Label(text) if markup: label.set_markup(text) label.set_property("visible", True) label.set_line_wrap(True) label.set_size_request(size, -1) return label # Wrap two widgets in horizontal box @staticmethod def hbox(w1, w2): b = gtk.HBox(homogeneous=False, spacing=10) b.set_property("visible", True) |
︙ | ︙ | |||
497 498 499 500 501 502 503 504 | # Expand A=a|B=b|C=c option list into (key,value) tuple list, or A|B|C just into a list. @staticmethod def parse_options(opts, sep="|", assoc="="): if opts.find(assoc) >= 0: return [ (k,v) for k,v in (x.split(assoc, 1) for x in opts.split(sep)) ] else: return opts.split(sep) #dict( (v,v) for v in opts.split(sep) ) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | # Expand A=a|B=b|C=c option list into (key,value) tuple list, or A|B|C just into a list. @staticmethod def parse_options(opts, sep="|", assoc="="): if opts.find(assoc) >= 0: return [ (k,v) for k,v in (x.split(assoc, 1) for x in opts.split(sep)) ] else: return opts.split(sep) #dict( (v,v) for v in opts.split(sep) ) #-- startup progress bar progresswin, progressbar = None, None def gui_startup(p=0/100.0, msg="streamtuner2 is starting"): global progresswin, progressbar if not progresswin: # GtkWindow "progresswin" progresswin = gtk.Window() progresswin.set_property("title", "streamtuner2") progresswin.set_property("default_width", 300) progresswin.set_property("width_request", 300) progresswin.set_property("default_height", 30) progresswin.set_property("height_request", 30) #progresswin.set_property("window_position", "center") progresswin.set_property("decorated", False) progresswin.set_property("visible", True) # GtkProgressBar "progressbar" progressbar = gtk.ProgressBar() progressbar.set_property("visible", True) progressbar.set_property("show_text", True) progressbar.set_property("text", msg) progresswin.add(progressbar) progresswin.show_all() try: if p<1: progressbar.set_fraction(p) progressbar.set_property("text", msg) while gtk.events_pending(): gtk.main_iteration(False) else: progresswin.hide() except: return |