473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Is there a way to create a button in either pygame or livewires?

Hey all,

Is there a way to create a button in either pygame or livewires, that is
able to be clicked and when clicked sends a command to restart the program?

Thanks,
Nathan Pinno

--
For great sites go to: http://www.the-web-surfers-store.com
MSN Messenger: falcon3166@hotmail,com
Yahoo! Messenger: spam_swatter31
ICQ: 199020705
AIM: f3mighty

--

.................................................. ............
Posted thru AtlantisNews - Explore EVERY Newsgroup <
http://www.AtlantisNews.com -- Lightning Fast!!! <
Access the Most Content * No Limits * Best Service <

Nov 22 '05 #1
4 4029
> Is there a way to create a button in either pygame or livewires, that is
able to be clicked and when clicked sends a command to restart the program?

You could try something like this using pygsear
(http://www.nongnu.org/pygsear/)

The button can call either start() which just makes
a new Game instance in the same process, or
full_restart() which starts a new process and quits
the current one.

from pygsear import Game, Widget
from pygsear.locals import RED
class G(Game.Game):
def initialize(self):
print 'starting up...'

self.button = Widget.SpriteTextButton(self.window, "Restart",
size=40, color=RED, padding=20)
self.events.add(self.button.events)
self.button.set_callback(self.restart)
self.button.set_position((200, 100))
self.sprites.add(self.button)

def restart(self, ev):
print 'restarting...'
#start()
full_restart()
self.quit = True

def start():
g = G()
g.mainloop()
def full_restart():
import os
import sys
cmd = 'python %s &' % sys.argv[0]
os.system(cmd)
if __name__ == '__main__':
start()

Nov 22 '05 #2
> Is there a way to create a button in either pygame or livewires, that is
able to be clicked and when clicked sends a command to restart the program?

You could try something like this using pygsear
(http://www.nongnu.org/pygsear/)

The button can call either start() which just makes
a new Game instance in the same process, or
full_restart() which starts a new process and quits
the current one.

from pygsear import Game, Widget
from pygsear.locals import RED
class G(Game.Game):
def initialize(self):
print 'starting up...'

self.button = Widget.SpriteTextButton(self.window, "Restart",
size=40, color=RED, padding=20)
self.events.add(self.button.events)
self.button.set_callback(self.restart)
self.button.set_position((200, 100))
self.sprites.add(self.button)

def restart(self, ev):
print 'restarting...'
#start()
full_restart()
self.quit = True

def start():
g = G()
g.mainloop()
def full_restart():
import os
import sys
cmd = 'python %s &' % sys.argv[0]
os.system(cmd)
if __name__ == '__main__':
start()

Nov 22 '05 #3
Nathan Pinno wrote:
Hey all,

Is there a way to create a button in either pygame or livewires, that is
able to be clicked and when clicked sends a command to restart the program?


Maybe something here:
http://www.pygame.org/wiki/gui

Kent
Nov 22 '05 #4
Nathan Pinno wrote:
Hey all,

Is there a way to create a button in either pygame or livewires, that is
able to be clicked and when clicked sends a command to restart the program?


Maybe something here:
http://www.pygame.org/wiki/gui

Kent
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andr? Roberge | last post by:
Sorry about the cryptic subject line, but I wanted to capture the essence of my message in a single line. I am learning Python (which, as everyone know is the best language :-) so that I can...
12
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels",...
3
by: Tim Knauf | last post by:
Hi everyone, I'm glad to have found this list. I've written a small script for my own use which, amongst other things, captures mouse click information from a window containing an image. I used...
2
by: Brent W. Hughes | last post by:
I'm just starting to learn pygame. I write what I think is just about the simplest program that should display a window and then quit. #----------------------------------------------- import sys...
0
by: Nathan Pinno | last post by:
Hey all, Is there a way to create a button in either pygame or livewires, that is able to be clicked and when clicked sends a command to restart the program? Thanks, Nathan Pinno -- For...
0
by: Lunpa | last post by:
My project: I'm working on a game, where in the ui, it takes the pygame window, and shoves it into a gtk2 socket widget. (gtk2 widgets are generated with glade, with the exception of the socket...
2
by: Blaze Bresko | last post by:
Hi, I am trying to make a game using either livewires or pygame. The game is tetris. Right now I have gotten the program to a point where everything works (as in user input, score, lines, etc),...
4
by: Iacopo.Marmo | last post by:
Hi! I need to manipulate multicolor strings, i.e. strings with a color associated with each letter. Any suggestions?
11
by: globalrev | last post by:
http://www.pygame.org/docs/ref/mixer.html import pygame #pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=3072) //it complained abiout words= so i guess its only the nbrs...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.