maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Python GTK/Hildon change button background (in fremantle) (https://talk.maemo.org/showthread.php?t=44170)

rambo 2010-02-11 21:27

Python GTK/Hildon change button background (in fremantle)
 
I have been driving myself crazy trying to do this, none of the EventBox tricks I found with google work in any usable way.

Basically I have a hildon.Button (also tried with plain gtk.Button) and I want to change the background color between red and green based on state changes.

Tried the following approaches:

1. Put the whole button inside eventbox and change eventbox background (the "official" GTK workaround to the fact that buttons do not generally allow background to be messed with), does "nothing" (ie the button with the default background and all is drawn on top of the eb).

2. Put the first child of the hildon.Button (gtk.Alignment) inside the eventbox: makes ugly mess where there is rectangular box inside the button area with the gray button borders visible, click only works if done in the gray border (i guess the eventbox could be connected to the signals as well, but since this looks fugly I didn't bother experimenting with that).

I wonder if I need to start reading hildon sources to figure out how exactly they build these widgets...

dalonso 2010-02-12 00:01

Re: Python GTK/Hildon change button background (in fremantle)
 
Isn't the default theme a pixmap one? Is it possible to change the background colors, then?

Darius2006 2010-02-12 01:01

Re: Python GTK/Hildon change button background (in fremantle)
 
hi,

just test basic python script

tried python2.4 example by Teemu

http://www.teemuharju.net/code/uitest.py

run under python2.5
generated errors

Traceback (most recent call last):
File "uitest.py", line 179, in <module>
uitest = UITest( )
File "uitest.py", line 16, in _init_
self.app = hildon.App( )
AttributeError: 'module' object has no attribute 'App'

(770, OS2008He, python2.5)

Any chance to have this hildon example to work

or how to contact Theemu

lizardo 2010-02-12 01:23

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by Darius2006 (Post 522274)
hi,

just test basic python script

tried python2.4 example by Teemu

http://www.teemuharju.net/code/uitest.py

If I understand correctly, you are trying to run this example on Diablo ? If I remember, "hildon.App" does not exist anymore there, and this example is terribly outdated :(

Darius2006 2010-02-12 01:40

Re: Python GTK/Hildon change button background (in fremantle)
 
@lizardo

this example is only 3 years old ;)

Any chance for GUI python2.5 examples to run on Diablo (2008He ?)

lizardo 2010-02-12 03:02

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by Darius2006 (Post 522304)
@lizardo

this example is only 3 years old ;)

Any chance for GUI python2.5 examples to run on Diablo (2008He ?)

You mean Maemo 5 (Fremantle) examples ? No :(

I suggest you take example code from existing projects on the diablo extras repository. Just find projects written in python (and which have functionality similar to what you want), and get sources from:

http://repository.maemo.org/extras-d...o/free/source/

Be careful to look at the code license, though.

Darius2006 2010-02-12 03:15

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by lizardo (Post 522386)
You mean Maemo 5 (Fremantle) examples ? No :(

I suggest you take example code from existing projects on the diablo extras repository. Just find projects written in python (and which have functionality similar to what you want), and get sources from:

http://repository.maemo.org/extras-d...o/free/source/

Be careful to look at the code license, though.


I don't mean Maemo 5 (Fremantle) examples.
Is diablo or 2008He a Fremantle ?

---
Originally Posted by Darius2006 View Post

@lizardo

this example is only 3 years old

Any chance for GUI python2.5 examples to run on Diablo (2008He ?)
---
Thanks for the repository as the previous posted was for Fremantle only with python2.5 examples

I am careful about .. but first I need to test anything working
under 2008He on 770 and please don't ask me if it's diablo or not (have no idea in secret codes ;)

My OS is 2008He on 770 + python2.5 installed
and just need to test few examples coming with GUI, clicable buttons, menu, just to see and learn what can be done with python2.5 and how fast a code can be run
as I use gpsbt lib to read gps data
and need to learn how to write basic
map tile (image) viewer, centering a map around GPS location.

If you are aware of any such python example and of it's name, just tell me.

Open image file (map tile)
get pin in the center and move map tile image
as GPS updates
nothing more , just for fun ;)

If your opinion is that python is not suitable for this task, just tell me in advance.

rambo 2010-02-12 06:45

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by dalonso (Post 522178)
Isn't the default theme a pixmap one? Is it possible to change the background colors, then?

I have no idea about the themes, however if "everything" is bitmaps how do they scale the buttons etc according to packing ?

Edit: Looking at theme maker it indeed looks like everything is done in bitmaps, so I guess the next thing is to figure how to bypass the theme and supply my own bitmaps (I could probably live with re-using the call-end and answer button backgound styles from the theme too, but how to do that ?)

rambo 2010-02-12 06:51

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by Darius2006 (Post 522395)
I don't mean Maemo 5 (Fremantle) examples.

as I use gpsbt lib to read gps data
and need to learn how to write basic
map tile (image) viewer, centering a map around GPS location.

If you are aware of any such python example and of it's name, just tell me.

Open image file (map tile)
get pin in the center and move map tile image
as GPS updates
nothing more , just for fun ;)

libchamplain has python bindings, so unless you have specific reasons for doing all the grunt work yourself I suggest checking it out first.

Codenames: http://wiki.maemo.org/Codenames

Quote:

Originally Posted by Darius2006 (Post 522395)
If your opinion is that python is not suitable for this task, just tell me in advance.

On 770 it might be a tad slow to start but in general should run fine, map panning (if implemented in pure python) might also be sluggish.

But I don't consider it unsuitable.

rambo 2010-02-12 07:36

Re: Python GTK/Hildon change button background (in fremantle)
 
On slightly off-topic note, anyone figure out why I fail to launch a python program from .desktop file but from terminal it works (See the files in SVN)

Basically the hotspot_frontend.py is copied to /usr/bin/mobilehotspot (see debian/rules for path details), clicking on the program entry in menu clearly does something but it would seem he thing crashes or something.

Running from terminal works.

twaelti 2010-02-12 08:39

Re: Python GTK/Hildon change button background (in fremantle)
 
Darius2006: I know your on another mission right now, but it is generally considered highly impolite to hijack a thread by posting other, quite unrelated questions.

twaelti 2010-02-12 08:48

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by rambo (Post 521945)
Basically I have a hildon.Button (also tried with plain gtk.Button) and I want to change the background color between red and green based on state changes.

1. Put the whole button inside eventbox and change eventbox background (the "official" GTK workaround to the fact that buttons do not generally allow background to be messed with), does "nothing" (ie the button with the default background and all is drawn on top of the eb).

2. Put the first child of the hildon.Button (gtk.Alignment) inside the eventbox: makes ugly mess where there is rectangular box inside the button area with the gray button borders visible, click only works if done in the gray border (i guess the eventbox could be connected to the signals as well, but since this looks fugly I didn't bother experimenting with that).

I spent yesterday evening right on the same problem, fighting with eventbox et. al., but couldn't yet find a solution.
Depending on your GUI layout, you might try to work with a gtk.Toolbar(), which then accepts a gtk.ToolButton() with an icon.
And this might help, too: PyGTK FAQ, How do I create buttons that contain a pixmap?

Darius2006 2010-02-12 22:08

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by twaelti (Post 522606)
Darius2006: I know your on another mission right now, but it is generally considered highly impolite to hijack a thread by posting other, quite unrelated questions.

@twaelti

You are completely wrong.
I am not on a mission as I am not a missionary.

lizardo is the right man for python questions on maemo and he was so kind to provide me with necessary python for diablo repository web link.
As number of python threads on maemo is today limited to very few, my question was highly relevant.

You developed maeMaps for N900 and I asked you about a version working on 770, as Nokia provided 770 owners with excellent OS 2008He upgrade, coming with GPS location.

You PM responded:
"
I'm unable and not interested :-)
"

"
I'm just not interested in outdated technology ;-)
"
from:
http://talk.maemo.org/showthread.php...hlight=maeMaps
you said:

"
For more independence, you can download it to your device and store it locally in MyDocs, then launch it through the File Manager and bookmark it from inside the Browser (Sometime in the future, I might package it for installation through the App manager). It also works on OS2008, as the location bar only covers the bottom line of the page.

It uses the Google Maps API v3, so no need for an API key.
"
maeMaps doesn't work launched locally as it does exactly come with API key as any Google Maps based app.


You are hereby requested to admit that you are sorry.

================
Nokia 770 Revitalization

rambo 2010-02-12 23:47

Re: Python GTK/Hildon change button background (in fremantle)
 
If all of you would please stay on topic from now on or open a new thread where you can discusss each others etiquette errors and other deficiencies.

Darious, you can also open new threads for python development discussion, PM me if you wish my comments to some thread (though I'm not really an expert).

Darius2006 2010-02-13 23:44

Re: Python GTK/Hildon change button background (in fremantle)
 
Quote:

Originally Posted by rambo (Post 524046)

Darious, you can also open new threads for python development discussion, PM me if you wish my comments to some thread (though I'm not really an expert).

@rambo
thanks for your kind offer

vitaminj 2010-08-15 21:21

Re: Python GTK/Hildon change button background (in fremantle)
 
At the risk of exhuming a long-dead thread, the answer to the semi-original question is to do a gtk_widget_set_name to hildon-accept-button-thumb (or finger) or hildon-reject-button-thumb (or finger) to trigger the red and green colours from the phone app.
Be aware though that obviously you are the mercy of theme makers as to whether the buttons will actually be red and green.


All times are GMT. The time now is 19:48.

vBulletin® Version 3.8.8