0

Struggling to get a simple form to work in a tkinter instance. Is there a known issue with not being able to click on tk.Entry boxes? I'll take the key parts of the code out to see if anyone can spot something i'm doing wrong?

class CreateWindow():
    def __init__(self):
        self.root = tk.Tk()
        self.root.overrideredirect(True)
        ***Then I do a whole load of importing images, setting background and other stuff ***
        self.messageText = tk.StringVar()
        self.MessageBox = tk.Entry(self.root, textvariable = self.messageText)
        self.MessageBox.place(x=100, y=100)
        self.root.mainloop()

This code is then called from if main = name

Does anyone see anything I'm doing wrong??

TheOuz
  • 47
  • 7
  • I never seen tk.root() before. For me it must be tk.Tk() – Thingamabobs Jun 30 '20 at 20:34
  • And you never placed the widget on your application. Somewhere you need to do self.Messagebox.pack() or another layoutmanager. – Thingamabobs Jun 30 '20 at 20:41
  • You may want to take a look at this before you follow and go ahead with your code. https://stackoverflow.com/questions/17466561/best-way-to-structure-a-tkinter-application – Thingamabobs Jun 30 '20 at 20:44
  • the mainloop() should be the last bit of code, except you want to run code after you close your window. Because the mainloop just reads the cod till it is called, everything beyond will not included. – Thingamabobs Jun 30 '20 at 20:50
  • Also set self to messageText, espacally with vars its recommanded to debugg. – Thingamabobs Jun 30 '20 at 20:56
  • My apologies. I typed my code out really badly. – TheOuz Jun 30 '20 at 21:57
  • `overrideredirect` on some systems inhibits the program from taking focus. Do you still see the problem if you remove the line that sets that option to True? – Bryan Oakley Jun 30 '20 at 23:10
  • @TheOuz Are you useing focus_force() somewhere ? – Thingamabobs Jul 01 '20 at 04:46
  • @BryanOakley I removed overrideredirect and am no longer experiencing the problem. Is there any way to work around this? I am producing a GUI that has many different functions. This specific slide needs to take user input to communicate with a server. However without the overrideredirect it no longer follows the design scheme of the rest of the windows – TheOuz Jul 02 '20 at 10:35

1 Answers1

1

The reason why I cannot click on the entry box is that root.overrideredirect(True) prevents the entry box from getting focus. I have listed a new question RPI Tkinter Window, I want to use a command like overrideredirect and maintain entry box functionality to focus on how to work around this.

TheOuz
  • 47
  • 7