FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: PyChan - Understanding widget styles/styling.py [for PARPG]  (Read 2804 times)

qubodup

  • Developer
  • Newbie
  • *
  • Posts: 15
    • View Profile
    • qubodup.net
PyChan - Understanding widget styles/styling.py [for PARPG]
« on: February 26, 2011, 10:31:26 am »

Hello people,

I am trying to change the default font but I also want to learn to use widget styles.

prock told me on #parpg to look at the widget style in the pychan example and I'm intrigued by styling.py but also confused.

1) If I understand correctly, I need to call "from styling import StylingExample" (assuming my syle function has the same name and file as fife-svn) at some point before drawing the gui.
2) I am confused by the line "from pychan_demo import PyChanExample" which is in styling.py (but also in all other files except pychan_demo.py). What is this for? Should this not cause an infinite loop (pychan_demo.py calling styling.py and vice versa)? I know it doesn't but I am probably too much of a python noob to understand the need for that line.

Sorry if these questions are stupid :)

Two unrelated things:
1. I have fife-svn installed, but I can't use the demos unless fife in the svn dir tree where the demos are located is compiled.
2. All python files refer to 'python' rather than 'python2'. This is a problem at least on Arch Linux, where python3 is default. (No idea if using python2 would break anything on other distros..)
Logged

qubodup

  • Developer
  • Newbie
  • *
  • Posts: 15
    • View Profile
    • qubodup.net
Re: PyChan - Understanding widget styles/styling.py [for PARPG]
« Reply #1 on: February 26, 2011, 06:25:39 pm »

I got the hint to look at UH's approach:

Quote
(1) http://trac.unknown-horizons.org/t/browser/horizons/gui/style.py (2) http://trac.unknown-horizons.org/t/browser/horizons/gui/widgets/tooltip.py#L84

this sets the font for 'tooltip' in any of our tooltip widgets

Thanks, eoc!
Logged

qubodup

  • Developer
  • Newbie
  • *
  • Posts: 15
    • View Profile
    • qubodup.net
Re: PyChan - Understanding widget styles/styling.py [for PARPG]
« Reply #2 on: February 26, 2011, 09:02:51 pm »

So... in horizons/engine.py, the following lines seem to be important:

Code: [Select]
import horizons.gui.style
[...]
class Fife(ApplicationBase):
[...]
    def init(self):
[...]
        for name, stylepart in horizons.gui.style.STYLES.iteritems():                                                 
            self.pychan.manager.addStyle(name, stylepart)

So I add a parpg/gui/style.py file and add to parpg/application.py the following:
Code: [Select]
import parpg.gui.style
[...]
class PARPGApplication(ApplicationBase):
[...]
    def __init__(self, setting):
[...]
        for name, stylepart in parpg.gui.style.STYLES.iteritems():
            pychan.manager.addStyle(name, stylepart)
but this does nothing yet.
(class and def __init__ lines already existed)

I'm off to bed. Let's see if I get somewhere tomorrow.
Logged

prock

  • Developer
  • Full Member
  • *
  • Posts: 236
    • View Profile
Re: PyChan - Understanding widget styles/styling.py [for PARPG]
« Reply #3 on: March 07, 2011, 09:10:21 am »

Thanks for posting your findings qubodup!!  I'm interested to hear how you get things going.
Logged