warum funktioniert das nicht? ich möchte nur gerne den text ausgeben den ich in meinem notepad window geschrieben habe.
und.. stimmt generell mein code so? bin mir noch sehr unsicher in sachen frames und so. (dank sei der docu das ich soweit gekommen bin bis jetzt *g*)
ganz unten bei "dev save_notepad" habe ich zum testen zwei zeilen code hinzugefügt... aber soweit kommt er nichtmal.
danke für die hilfe
diese fehlermeldung bekomme ich nachdem ich auf den "save" button geklickt habe.
Code: Alles auswählen
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Programme\Python\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "E:\PRIVAT\Experiments\_CODING\_python\s-s-s_client\dev\s-s-s_client.py",
line 92, in save_notepad
notes = notepad_text.get("1.0", END)
NameError: global name 'notepad_text' is not defined
Code: Alles auswählen
############################################
# SECRET-SOUND-SERVICE - Info Client 0.2 #
############################################
# Author : arT2 #
# Email : mail at tripz dot ch #
# Home : http://tripz.ch #
# Python : Version 2.3 (#46, Jul 29 2003) #
############################################
### config #################################
playlist_file = "http://xxxxxx.ch/np.php"
script_name = "Info Client"
script_version = "0.2"
script_author = "xxx"
script_author_m = "xxx"
############################################
from Tkinter import *
from ScrolledText import *
import urllib
############################################
# PLAYLIST FRAME
class Playlist:
def __init__(self,master):
frame_playlist = Frame(master)
frame_playlist.grid()
# windows
playlist_text = ScrolledText(width=60, height=13)
# buttons
b_refresh = Button(master, text="refresh", command=self.get_playlist)
# labels
l_playlist = Label(master, text="< playlist")
# grid manager
playlist_text.grid(row=0)
l_playlist.grid(row=0, column=2, sticky=NW)
b_refresh.grid(row=0, column=2, sticky=SW)
# fetch playlist
def get_playlist(self):
print "DEBUG 1 XXX XX XX XXX X"
## # clear playlist window
## playlist_text.delete('1.0', END)
##
## #get raw data
## playlist_raw = urllib.urlopen(playlist_file)
##
## # create list
## playlist = [playlist_raw.readlines(0)]
##
## while i < len(playlist):
## playlist_text.insert(END, playlist[i])
# NOTEPAD FRAME
class Notepad:
def __init__(self,master):
frame_notepad = Frame(master)
frame_notepad.grid()
# windows
notepad_text = ScrolledText(master, width=60, height=5)
# buttons
b_save = Button(master, text="save", command=self.save_notepad)
# labels
l_notepad = Label(master, text="< notepad")
# grid manager
notepad_text.grid(row=1)
l_notepad.grid(row=1, column=2, sticky=NW)
b_save.grid(row=1, column=2, sticky=SW)
def save_notepad(self):
notes = "foobarbarbarbarb"
notes = self.notepad_text.get("1.0", END)
print "DEBUG 2 XXX XX XX XXX X"
root = Tk()
root.title(script_name + ' ' + script_version)
app = Playlist(root)
app = Notepad(root)
root.mainloop()