This is my server script when running it without GUI the start method only it works fine but when running the whole script and I press the start button it just freezes and not responding and nothing appears on the text window - from Tkinter import *
-
-
import socket
-
import sys
-
-
class Application(Frame):
-
-
def __init__(self, master):
-
-
Frame.__init__(self, master)
-
self.grid()
-
self.create_widgets()
-
-
def create_widgets(self):
-
-
self.text = Text(self, width = 35, height = 5, wrap = WORD)
-
self.text.grid(row = 0, column = 0, columnspan = 2, sticky = W)
-
-
self.submit_button = Button(self, text='start', command = self.start)
-
self.submit_button.grid(row = 2, column = 0, sticky = W)
-
-
def start(self):
-
-
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
self.text.insert(0.0, 'Server started!\n' )
-
self.s.bind(('',1090))
-
self.s.listen(10)
-
sc, address = self.s.accept()
-
self.text.insert(0.0, 'Got conn from', address )
-
while True:
-
-
'''msg = sc.recv(1024)
-
print address, ' >> ', msg
-
msg = raw_input('SERVER >> ')
-
sc.send(msg)'''
-
i=1
-
f = open('file_'+ str(i)+".txt",'wb') #open in binary
-
i=i+1
-
while (True):
-
l = sc.recv(1024)
-
while (l):
-
print l
-
f.write(l)
-
f.flush()
-
l = sc.recv(1024)
-
f.close()
-
-
sc.close()
-
-
#s.close()
-
-
-
root = Tk()
-
root.title("Server")
-
root.geometry("500x250")
-
app = Application(root)
-
-
root.mainloop()
3 3077
Add a print statement at the beginning of start() and another after the socket statement to see if that is the hang-up, as the Tkinter code appears to work ok. Note that the inner "while True" statement never exits so the outher while True will only execute once.
It appears that Tkinter requires an update_idletasks() because of all of the other processing going on. - self.text.insert(0.0, 'Server started!\n' )
-
self.text.update_idletasks()
-
-
self.text.insert(0.0, 'Got conn from', address )
-
self.text.update_idletasks()
The hang-up now appears to be this line - sc, address = self.s.accept()
i am new to socket programming ana i saw that the problem with accepting the connection but it was working well before buiding the GUI i dont know what to do
Sign in to post your reply or Sign up for a free account.
Similar topics
by: george.trojan |
last post by:
My application consists of Tkinter GUI that has to communicate with a
remote
server. The communication is bi-directional: the GUI responds to remote
requests and user actions uch as pressing a...
|
by: Noah |
last post by:
I have a long running application with a Tkinter GUI.
Is there a way to see how many events are pending in the queue?
I want my application to occasionally process events (so that the
output...
|
by: Bob Greschke |
last post by:
I have a program where the user pushes a button, a "starting" message is
..inserted to a text field with an associated scroll bar, a thread is started
that inserts a "working..." message on to the...
|
by: corrado |
last post by:
Hello
I have an application running several thread to display some financial
data;
basically I have a thread displaying HTML tables by means of Tkhtml,
another implementing a scrolling ticker...
|
by: Michael Zhang |
last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images
from server and display those images.
I created a thread (also a separate toplevel window) for displaying
images and another...
|
by: srihari |
last post by:
Hai,
I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My
machine is Intel XEON 64bit. The installation went well except for the
creation of tools catalog. When I tried to install the tools...
|
by: Marcin Szarek |
last post by:
Hi!
For a few months we suffer mysterious problem with Oracle 10g RAC (more
details on server configuration at the bottom). At regular basis (every 5
minutes) nodes of our cluster "freeze" -...
|
by: vedran_dekovic |
last post by:
Hi,
I need help about Tkinter listbox widget.I want,when somebody click on
any item(file) in Listbox,then in new Label widget text must be
selected item from server.
my program (wrong...
|
by: Kevin Walzer |
last post by:
I'm a Tcl/Tk developer who has been working, slowly, at learning Python,
in part because Python has better support for certain kinds of
applications that I want to develop than Tcl/Tk does....
|
by: bg_ie |
last post by:
Hi,
I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |