[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] pgu file widget
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] pgu file widget
- From: Phil Hassey <philhassey@xxxxxxxxx>
- Date: Sat, 3 Dec 2005 10:50:19 -0800 (PST)
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Sat, 03 Dec 2005 13:50:24 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=sgp/iFbMAu4CFwOItio8ox+DIZcbMIZGLx75VNjehUF1OyYC0qhwB/cCN0EqQFd9LxsITWRox7BchvBJ0VQqYEsf4rLMMUFZLjpuPU2bacMRhaJPwvtZ4tBhS1oUIg/Bv/EVpBS86NkSKe2RjBfPItjRxIBV6ECv9RlxttshS/k= ;
- In-reply-to: <f495db580512022128x571e28d6yc3c8a78cfe7aca67@mail.gmail.com>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
input_file isn't a global variable, so
handle_file_browser will not work.
Same reason this won't work:
def test_1():
coconuts = "i like coconuts"
def test_2():
print coconuts
test_1()
test_2()
--- Knapp <magick.crow@xxxxxxxxx> wrote:
> Can any one make this work? I am very new to all
> this and a bit lost
> at this point. Note that it is example gui12.py but
> with the second
> half in a def.
>
> Problem is that input_file can not be seen in def
> handle_file_browser_closed(dlg)
>
> import sys
> sys.path.insert(0, '..')
>
>
> import pygame
> from pygame.locals import *
> from pgu import gui
>
> def open_file_browser(arg):
> d = gui.FileDialog()
> d.connect(gui.CHANGE,
> handle_file_browser_closed, d)
> d.open()
>
> def handle_file_browser_closed(dlg):
> if dlg.value: input_file.value = dlg.value
>
> #gui.theme.load('../data/themes/default')
> def mainapp():
> app = gui.Desktop()
> app.connect(gui.QUIT,app.quit,None)
>
> main = gui.Container(width=500, height=400) #,
> background=(220, 220, 220) )
>
> main.add(gui.Label("File Dialog Example",
> cls="h1"), 20, 20)
>
> td_style = {'padding_right': 10}
> t = gui.Table()
> t.tr()
> t.td( gui.Label('File Name:') , style=td_style )
> input_file = gui.Input()
> t.td( input_file, style=td_style )
> b = gui.Button("Browse...")
> t.td( b, style=td_style )
> b.connect(gui.CLICK, open_file_browser, None)
>
> main.add(t, 20, 100)
>
> app.run(main)
> if __name__ == '__main__': mainapp()
>
__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com