|
2009-09-09
, 10:51
|
|
Posts: 299 |
Thanked: 168 times |
Joined on Jun 2006
@ Wales UK
|
#22
|
#!/usr/bin/env python2.5 import gtk from gtk import gdk Has_hildon=False try: import hildon,osso Has_hildon=True except: pass class fontsize(): def on_key_press(self,widget,event,*args): if event.keyval == gtk.keysyms.F7: self.fsize += 1 #inc if event.keyval == gtk.keysyms.F8: self.fsize -= 1 #dec Settings=gtk.settings_get_for_screen(gdk.screen_get_default()) Style=self.Style1 + str(self.fsize) + self.Style2 gtk.rc_parse_string(self.Style1 + str(self.fsize) + self.Style2) gtk.rc_reset_styles(Settings) def Quit(self,n): gtk.main_quit() def __init__(self): self.fsize=12 self.Style1=\ """ style "general-font" { font_name = "Sans """ self.Style2=\ """ " } widget_class "*" style "general-font" """ gtk.rc_parse_string(self.Style1 + str(self.fsize) + self.Style2) if Has_hildon: self.program=hildon.Program() self.program.__init__() self.window = hildon.Window() else: self.window = gtk.Window() self.window.set_default_size(800,480) self.window.connect("delete_event",self.Quit) self.window.connect("key-press-event",self.on_key_press) self.Lab=gtk.Label("This text should change size ...") self.Box=gtk.VBox(True,0) self.CBox = gtk.combo_box_new_text() for f in ("Some Arbitary Text","Maemo Rules","N900 Rocks"): self.CBox.append_text(f) self.Btn=gtk.Button("Quit") self.Btn.connect("clicked",self.Quit) self.window.add(self.Box) self.Box.pack_start(self.Lab,False,False,0) self.Box.pack_start(self.CBox,False,False,0) self.Box.pack_start(self.Btn,False,False,0) self.window.show_all() def run(self): gtk.main() if __name__ == "__main__": try: osso_context = osso.Context("net.nokia.fontsize","0.1",False) except Exception,e: if repr(e).find("NameError") == 0: pass else: print "Error when testing for osso" app=fontsize() app.run()
|
2009-09-09
, 20:42
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#23
|
|
2009-09-10
, 07:24
|
|
Posts: 299 |
Thanked: 168 times |
Joined on Jun 2006
@ Wales UK
|
#24
|
The Following User Says Thank You to rcull For This Useful Post: | ||
|
2009-09-10
, 14:22
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#25
|
|
2009-09-15
, 00:50
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#27
|
|
2009-09-16
, 05:46
|
|
Posts: 299 |
Thanked: 168 times |
Joined on Jun 2006
@ Wales UK
|
#28
|
|
2009-09-16
, 14:12
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#29
|
luis
You will need to read up on gtkrc but you are not restricted to one style ie.
Rick
|
2009-09-17
, 02:32
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#30
|
def makefont(self): Settings=gtk.settings_get_for_screen(gdk.screen_get_default()) gtk.rc_parse_string(""" style "general-font" { font_name = "Sans """+str(self.font)+""" " } style "out-font" { font_name = "Sans """+str(self.font+6)+""" " } style "label-font" { font_name = "Sans bold """+str(self.font-4)+""" " } class "*" style "general-font" class "GtkTreeView" style "out-font" class "GtkLabel" style "label-font" """) gtk.rc_reset_styles(Settings)
Thanks,
L.