1

I have my principal script running with terminal that works perfectly. Im trying to make a gui for it but im stuck at this point. Principal Terminal Version Like you see on the screen, at the start of the script it asks if it should check the database. And just after, it asks first the platform before opening the captcha for the database check. The problem happens exactly here on my GUI version, look. Gui Version Like you see, the gui starts, but when i click on check for new database, it directly opens the captcha without asking the platform... And it asks me the platform only after i solved the captcha which i dont want to after...

Here is the main testkinter.py code:

import tkinter as tk
from tkinter import messagebox
import commands
import CheckDatabase
import SetPlatformfile



def check_and_hide():
    CheckDatabase.db_download(root)
    checkdb.pack_forget()
    checkdb1.pack_forget()


root = tk.Tk()


checkdb = tk.Button(root, text="Check for new databases", command=check_and_hide)
checkdb.pack()


checkdb1 = tk.Button(root, text="No")
checkdb1.pack()


root.mainloop()

Here is the set_platform function called in the Checkdatabse file:

import tkinter as tk
import config
from tkinter import messagebox



def set_platform(root):
    platform = tk.Label(root,text="'a'|Android -- 'i'|iOS: ")
    platform.pack()
    androidbutton=tk.Button(root,text="Android",command=renameplatformandroid)
    iosbutton=tk.Button(root,text="iOS",command=renameplatformios)
    androidbutton.pack()
    iosbutton.pack()


def renameplatformandroid():
    config.platform = 'android'
    print(config.platform)

def renameplatformios():
    config.platform = 'ios'
    print(config.platform)

And cuz of my checkdatabase file is really really long, i'll just put a screen at the exact moment where set_platform is called (its called in the func signup which itself is directly called at the beginning of db_download) . Set platform called

I hope my question is clear! Let me know if you need more details.

Community
  • 1
  • 1
Ace
  • 53
  • 8
  • As Bryan Oakley said in an [answer](https://stackoverflow.com/a/9343402/355230) to a different, unrelated, `tkinter` [question](https://stackoverflow.com/questions/9342757/tkinter-executing-functions-over-time), "Event-driven programming requires a different mindset from procedural code. Your application is running in an infinite loop, pulling events off of a queue and processing them." All your `set_platform(root)` function does is create a couple of `Button`s — it doesn't wait for one of them to be clicked. – martineau Jun 08 '19 at 16:59
  • @martineau ok now i got the mindset for it. But it still doesnt resolves my problem. I tried adding "after" behind my buttons but when i do that when i click on "check new databases" it just wait the time i've put in the "after" before continuing, still without showing the platform func – Ace Jun 08 '19 at 18:53
  • Ace: As I tried to indicate, the other question (and its accepted answer) isn't strictly related to yours — except for what Bryan said about GUIs being event-driven processes (I like to cite authoritative references). To do what you're trying to do, I suggest you consider using [easygui](https://pypi.org/project/easygui). If nothing else, you can look at its source code and see how it does things. – martineau Jun 08 '19 at 19:03

0 Answers0