GUI

15 views
Skip to first unread message

Derick

unread,
Apr 26, 2009, 2:03:24 PM4/26/09
to pyglet-users
I've been working on a GUI lately, and its gotten into fairly workable
state, so I figured I would upload it. Its still in pretty rough
shape, but the following widgets are available:

- Label
- Static Image
- Button
- Check Box
- Radio Button
- Edit Box
- Slider
- Scroll Bar
- List Box
- Progress Bar

Check Box is really more of a 'multi-state box'; it allows a user-
defined number of states, and each time its clicked, the current state
is incremented. When the current state reaches the maximum number of
states, it rolls back to 0. Its defaulted to 2 states, which is
essentially a normal check box.

List Boxes can have multiple columns, and a header bar (with a button
for each column, which doesn't do anything currently). You can also
theoretically use any widget type as an element in the list. I have
written implementations for what I figure to be the most common -
basic text, check box, and image.

Its intended to be API-agnostic, but I've written a basic pyglet
implementation for it. Performance isn't really that great yet, as the
focus has been more on functionality.

Here's a link to the download:
http://code.google.com/p/pygag/

Included are also a couple demos. One creates the widgets
programmatically, while the other loads layout information from an
external file.

Steve

unread,
Apr 26, 2009, 4:39:32 PM4/26/09
to pyglet-users
I just tried demo.py. Mouse clicks don't appear to do anything.

Derick

unread,
Apr 26, 2009, 8:28:54 PM4/26/09
to pyglet-users
So, none of the widgets are responding to mouse clicks? You're not
able to click the button, check the check box, move the slider, or
select an item from the list box? Did the button, check box, or any of
the radio buttons darken a bit when the mouse cursor is over them?
This should also be happening.

I just tried downloading it again, and didn't have any problems
running it. Which version of Python and Pyglet are you using? As I
mentioned in the readme file, I've been developing against Python
2.5.2 and Pyglet 1.1.2. I'm guessing the Python version doesn't matter
much. From the sounds of it, the differences from Pyglet 1.1.2 to
1.1.3 are mostly bug fixes and the like, so I'm not sure that's the
problem, either.

Gary Herron

unread,
Apr 26, 2009, 8:54:43 PM4/26/09
to pyglet...@googlegroups.com
Derick wrote:
> So, none of the widgets are responding to mouse clicks? You're not
> able to click the button, check the check box, move the slider, or
> select an item from the list box? Did the button, check box, or any of
> the radio buttons darken a bit when the mouse cursor is over them?
> This should also be happening.
>
> I just tried downloading it again, and didn't have any problems
> running it. Which version of Python and Pyglet are you using? As I
> mentioned in the readme file, I've been developing against Python
> 2.5.2 and Pyglet 1.1.2. I'm guessing the Python version doesn't matter
> much. From the sounds of it, the differences from Pyglet 1.1.2 to
> 1.1.3 are mostly bug fixes and the like, so I'm not sure that's the
> problem, either.
>


I too experienced the same problem. I haven't looked into it yet (and
won't be able to for several days), but here's a hint:

If I click near the top of the window, well above the listbox, I can get
the listbox to respond with a changing of the highlighted line. Moving
slight up/down can select about the lower half of the lines in the
listbox. So it appears the mouse y-position map is off. The x-position
map might be OK, but it's hard to tell.

Hope that helps somewhat.

Gary Herron

rwa...@googlemail.com

unread,
Apr 27, 2009, 6:16:46 AM4/27/09
to pyglet-users
I had the same problem. On one occasion I found that clicking near the
lower right corner of the vertical scroll bar had the effect of
clicking on the check box (ie x and y mouse position is off). But it
was inconsistent. Otherwise I wasn't able to have any effect with
mouse clicks.
The gui looks nice though

Tristam MacDonald

unread,
Apr 27, 2009, 8:18:36 AM4/27/09
to pyglet...@googlegroups.com
On Sun, Apr 26, 2009 at 8:28 PM, Derick <deric...@hotmail.com> wrote:

So, none of the widgets are responding to mouse clicks? You're not
able to click the button, check the check box, move the slider, or
select an item from the list box? Did the button, check box, or any of
the radio buttons darken a bit when the mouse cursor is over them?
This should also be happening.

Just tried it on my Mac, runnign python 2.5 and the latest from the pyglet 1.1-maintenance branch. All the controls in the left-hand column seem to work, but the mouse position is offset by about 300 pixels along the x-axis. Because of this, I can't try the controls to the right, since the offset places my mouse outside the window...

--
Tristam MacDonald
http://swiftcoder.wordpress.com/

edexter

unread,
Apr 27, 2009, 11:09:13 AM4/27/09
to pyglet-users
It seems to work all right on mine.... If I click on the text near
the check box it selects the box, I am sure that is not standard
behavior... I have been looking at gui's and the example looks like
the easist to follow, but I haven't tried using it yet. I don't realy
understand how to use the other ones I have looked at outside of thier
'context'. I would like to see a checkbox like button with two boxes
an outside box and a smaller inside box that changes color when
clicked..

On Apr 27, 7:18 am, Tristam MacDonald <swiftco...@gmail.com> wrote:

Derick

unread,
Apr 27, 2009, 1:12:59 PM4/27/09
to pyglet-users

For everyone who is having problems, are you all on a Mac?

It kind of sounds like the initial position for the mouse cursor isn't
being passed properly at start up, which would explain the rather
inconsistent results. I am unsure why it works for some, but not for
others.

On Apr 27, 8:09 am, edexter <Eric_Dex...@msn.com> wrote:
> It seems to work all right on mine.... If I click on the text near
> the check box it selects the box, I am sure that is not standard
> behavior...

I tried some other examples around on the web, and I'm not sure there
really is a 'standard' behavior. Sometimes clicking the text would
cause the check box to be selected; other times it didn't.

Carl Witty

unread,
Apr 27, 2009, 1:23:28 PM4/27/09
to pyglet...@googlegroups.com
On Mon, Apr 27, 2009 at 10:12 AM, Derick <deric...@hotmail.com> wrote:
>
>
> For everyone who is having problems, are you all on a Mac?

No; I have similar problems under Linux.

Carl

Gary Herron

unread,
Apr 27, 2009, 1:38:38 PM4/27/09
to pyglet...@googlegroups.com
Derick wrote:
> For everyone who is having problems, are you all on a Mac?
>

Nope. I'm using Linux on an HP laptop with a recent Nvidia card.

Gary Herron

Greg Ewing

unread,
Apr 27, 2009, 8:29:45 PM4/27/09
to pyglet...@googlegroups.com
edexter wrote:
> It seems to work all right on mine.... If I click on the text near
> the check box it selects the box, I am sure that is not standard
> behavior...

It's the normal behaviour on most desktop GUIs I've
used. It makes sense to give the user as big a target
as possible, since big targets are easier to hit than
small ones.

--
Greg

Greg Ewing

unread,
Apr 27, 2009, 9:05:22 PM4/27/09
to pyglet...@googlegroups.com
Derick wrote:
>
> For everyone who is having problems, are you all on a Mac?
>
> It kind of sounds like the initial position for the mouse cursor isn't
> being passed properly at start up

Could it be a matter of screen vs. window coordinates?
Does moving the window make any difference to the results?

--
Greg

edexter

unread,
Apr 27, 2009, 9:56:43 PM4/27/09
to pyglet-users
where do I look if I want to replace the graphics ie. the .png picture
with a square exc... ??? I want to try to make some changes to be
able change the color exc. exc. I have one in pycap that I want to
port over.. I was thinking of calling it a toggle.

Derick

unread,
Apr 28, 2009, 4:12:43 PM4/28/09
to pyglet-users
In an attempt to try and figure out why the mouse isn't working
properly, I've added a new download at

http://code.google.com/p/pygag/

called pygagtest. Its basically the same download as before, but there
are two additional files.

The optimistically named 'fix.py' file tries passing the mouse
position slightly differently than before. Originally, I was only
keeping track of updates to the mouse position; now, I'm passing in
the absolute coordinates. Normally, when I run the program, pyglet
posts a mouse motion event immediately, even before the mouse moves,
with the motion values effectively equal to the current position. I'm
not sure this is happening in all cases.

The second file is called 'mousetest.py'. It simply makes a log file
(log.txt) of where the gui believes the mouse is currently located. If
some of you who are having could run this program, and post the
results, I would appreciate it. Probably the best thing to do is click
the mouse near the 4 corners of the window, and let me know which
corner is associated with each set of values. This might give me an
idea of what's going on.

Thanks.

Derick

unread,
Apr 28, 2009, 4:29:58 PM4/28/09
to pyglet-users

On Apr 27, 6:56 pm, edexter <Eric_Dex...@msn.com> wrote:
> where do I look if I want to replace the graphics ie. the .png picture
> with a square exc...  ???  I want to try to make some changes to be
> able change the color exc. exc.  I have one in pycap that I want to
> port over..  I  was thinking of calling it a toggle.

I wouldn't really call this version 'production ready', so you may
want to hold off on using it too much. It was mostly an attempt to
iron on the major bugs, such as this mouse coordinates one.

To answer your question, to keep things simple for the download, I'm
mostly just using untextured quads for what you're seeing, so you
won't find an external image file. Without going into too many
details, and if I understand what you are looking for, use the
widget's setTexture function. It would look something like:

widget = CheckBox((0.1, 0.15), (0.1, 0.025), text = 'Check Box')
widget.setTexture(fileName)
...

where fileName is the location of the image file. There are also two
additional, optional parameters for the function - color and idx.
color is the color you want to use for the texture (defaults to the
pygag-defined color value WHITE (1.0, 1.0, 1.0, 1.0)). idx is the
index in the list of textures for the widget you want to set (defaults
to 0). idx allows you to have multiple textures for the widget, if
desired.

However, if you just want to change the color, without using a
texture, just use the setColor function. The first parameter is the
color you want. The second, optional parameter is idx, which works
like the setTexture parameter. For a list of predefined colors, look
at the colors.py file in the utilities folder.

rwa...@googlemail.com

unread,
Apr 29, 2009, 5:19:09 AM4/29/09
to pyglet-users
As above, I had problems with the original download (on OS X 10.5.6,
python 2.52). fix.py seemed to work fine, although I couldn't make the
image button or the horizontal thermometer-looking widget do anything.
mousetest.py gave the following results
-266,525 -- upper left
512,522 -- upper right
506,-57 -- lower right
-237,-57 -- lower left
moving the window around and retesting gave basically the same values

Derick

unread,
Apr 29, 2009, 10:21:39 PM4/29/09
to pyglet-users
Thanks for running that. The totals you received have roughly the
proper range (800x600) for the window, but are offset for some reason.
And, from the sounds of it, the offset isn't the same for everyone.
From the responses so far, it seems as though it isn't working on non-
Windows machines (or, at least, Linux and Mac).

The image button isn't really a button; its just a static image. There
isn't any functionality attached to it, so there's nothing you can do
with it. Same with the horizontal bar. Its actually a progress bar,
which generally doesn't allow any sort of user interaction. I probably
should have labeled all of the elements.

On Apr 29, 2:19 am, "rwar...@googlemail.com" <rwar...@googlemail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages