tkinter - Python grid_forget -


i ask regarding this.

i'm trying clear frame adding new elements in it. however, after clearing elements, adding new elements not show. can please shed light regarding problem. thanks

here's code

#!/usr/bin/env python  import tkinter tk import socket import sys  def next(line, num):     s.send(line)     data= s.recv(size)     num.set(data)  class client(tk.frame):      def __init__(self, master=none):         tk.frame.__init__(self, master)         self.grid()         self.confighost()      def confighost(self):         self.hostentry = tk.entry(self, justify=tk.center);         self.hostlabel = tk.label(self, text='host')         self.connectbutton = tk.button(self, text='connect', command=lambda:self.startserve())          self.hostlabel.grid(row=0, column=0, ipadx=10, ipady=10)         self.hostentry.grid(row=0, column=1, columnspan=4, pady=20, padx=20, ipadx=5, ipady=5)         self.connectbutton.grid(column=2,pady=10)      def startserve(self):         hostnum = self.hostentry.get()         port = 50000         size = 1024         s = socket.socket(socket.af_inet, socket.sock_stream)         s.connect((hostnum,port))          if s >= 0:             self.grid_forget()             tk.frame.__init__(self, master=none)             self.grid()                  self.nowservinglabel= tk.label(self, text="sample")              self.button = tk.button(self, text='connect')             self.nowservinglabel.grid()             self.button.grid() 

it highly unusual call frame constructor more once. root of problem. have no idea under covers, classes aren't designed work way.

also, aware grid_forget removes widget view, doesn't destroy it? if keep "forgetting" , recreating widgets, you're creating memory leak.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -