pygButton

pygButton

Postby Terex » Mon Jun 23, 2014 1:57 pm

i am using the pygbutton to develop an application
my first scripts calls the pygbutton to display buttons on screen
and the in that same scripts i want to use one of the buttons to link to another script
(creating something like a navigation) that also gas buttons in it and calls the pygButton.py scripts
when i use the simple "import script" it does not work
please how can fix this issue
Terex
 
Posts: 4
Joined: Mon Jun 23, 2014 1:50 pm

Re: pygButton

Postby metulburr » Mon Jun 23, 2014 2:50 pm

I am assuming you are using this guys button UI from pygame?
http://www.pygame.org/project-PygButton-2709-.html

in his file he has a class called PygButton so i would try:
Code: Select all
from pygbutton import PygButton


pygbuttons.py class header
Code: Select all
class PygButton(object):
    def __init__(self, rect=None, caption='', bgcolor=LIGHTGRAY, fgcolor=BLACK, font=None, normal=None, down=None, highlight=None):


Other than that i have not looked into his code more in depth, so the inner workings are for you to figure out. If it becomes too cumbersome, you can just create your own button class. I would preferr a button class made by mekire though , https://github.com/Mekire/pygame-button
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: pygButton

Postby Terex » Tue Jun 24, 2014 9:56 am

thank you so much
i tried the from pygbutton import PygButton
and it didn't work
and i also followed that link but noticed that i didn't quite see a line for declaring an
action on click to import another python scripts
Terex
 
Posts: 4
Joined: Mon Jun 23, 2014 1:50 pm

Re: pygButton

Postby metulburr » Tue Jun 24, 2014 11:24 am

and i also followed that link but noticed that i didn't quite see a line for declaring an
action on click to import another python scripts

the button class handles all of its own events. So you only need the line in check_event in your own code. The on click is handled inside the button class upon a click event. So all you really need to do is create a button object with it attributes inside a dict, and check its event to update the button, such as in his example.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: pygButton

Postby Mekire » Tue Jun 24, 2014 11:43 am

i didn't quite see a line for declaring an action on click to import another python scripts

Is this actually what you mean? Are you trying to dynamically import specific modules on button click? Or do you just want to run a specific function on button click. The latter is very simple; the former is trickier (but definitely doable if it is really, truly what you need).

-Mek
User avatar
Mekire
 
Posts: 987
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygButton

Postby Terex » Wed Jun 25, 2014 10:54 am

Am trying to create something like a navigation
a "Go" button on one scripts and then a "Back" button on another script.
Both scripts use the PygButton class on the pygbutton script
making a total of 3 scripts

Scripts 1: on button click "Go" will call scripts 2
and Scripts 2 has the "Back" button and on click
will return to Scripts 1
but both of them use the PygButton class on a pygbutton script
And it dosent work by simply importing Scrits 2 from Scripts 1

Thank You
Terex
 
Posts: 4
Joined: Mon Jun 23, 2014 1:50 pm

Re: pygButton

Postby Mekire » Wed Jun 25, 2014 10:59 am

It sounds like you want a rudimentary scene manager, but your terminology is getting a bit strange.

Lets try to get this straight.
You want a screen with a button that makes another screen appear.
The second screen has a back button that will return to the first.

Is this correct?

Please post or link to the code you have so far.
-Mek
User avatar
Mekire
 
Posts: 987
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygButton

Postby Terex » Thu Jun 26, 2014 8:42 pm

Yes this is very correct
do you have any idea, what i can do
Terex
 
Posts: 4
Joined: Mon Jun 23, 2014 1:50 pm


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests