Hallo zusammen,
Ich möchte bez. habe schon ein Gui mit Phyton erstellt, nun möchte ich mit Hilfe der einzelnen Buttons TCP Befehle senden.
Bis jetzt habe ich die Gui (schlichtes Designe) und versuche zurzeit eine TCP Verbindung aufzubauen.
Mein Code :
Python
from tkinter import *
from tkinter import ttk
import sys
from socket import *
## Versuch TCP Client
TCP_IP = '192.168.61.91'
TCP_PORT = 8052
BUFFER_SIZE = 1024
MESSAGE = "Hello, World!"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()
print ("received data:"), data
## Form (TK) schliessen
def close_window ():
root.destroy()
## Deklaration Tk (Form)
root = Tk()
root.title("Präsentation")
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
## Alle Buttons und Labels
ttk.Label(mainframe, text="Kalender").grid(column=3, row=2, sticky=W)
ttk.Button(mainframe, text="Kalender Termine", command=close_window).grid(column=3, row=3, sticky=W)
ttk.Label(mainframe, text="Fotos").grid(column=3, row=8, sticky=W)
ttk.Button(mainframe, text="Präsentation", command=close_window).grid(column=3, row=9, sticky=W)
ttk.Label(mainframe, text="Video").grid(column=3, row=14, sticky=W)
ttk.Button(mainframe, text="Video Abspielen", command=close_window).grid(column=3, row=15, sticky=W)
ttk.Button(mainframe, text="DE", command=close_window).grid(column=4, row=15, sticky=W)
ttk.Button(mainframe, text="EN", command=close_window).grid(column=5, row=15, sticky=W)
ttk.Button(mainframe, text="EN", command=close_window).grid(column=6, row=15, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
root.mainloop()
Alles anzeigen
Zurzeit verweisen alle Buttons auf "schliessen".
Wenn ich nun mein Python Programm starte kommt:
ZitatTraceback (most recent call last):
File "C:\Python34\Praesentation.py", line 13, in <module>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: type object 'socket' has no attribute 'socket'
Und zwar hier: