وصال وفایی
2 سال پیش توسط وصال وفایی مطرح شد
4 پاسخ

من دارم یه برنامه دسکتاپ با tkinter مینویسیم ولی به مشکل بر خوردم

من دارم برنامه دسکتاپ با پایتون مینویسیم ولی وقتی یه لیبل جدا باز میکنم و پایینش یه entry توی دوتا پنجره جدا به من نشون میده
حتی وقتی یه ویندو کانفیگور باز میکنم و تغیرات رو اعمال میکنم پنجره تنظیم شده رو توی یه پنجره دیگه نشون میشه

    global operator
    operator = operator + str(numbers)
    text_input.set(operator)
def btnClearDisplay():
    global operator
    operator =""
    text_input.set("")
def btnEqualsInput():
    global operator
    sumup = str(eval(operator))
    text_input.set(sumup)
    operator=""
cal = Tk()
cal.title("Vesal Calculator")
operator = ""
text_input = StringVar()
window = tkinter.Tk()
root = Tk()
window.configure(bg="WHITE", height='300px ', width='300px', cursor="wait")               
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*     Welcome to this programm;       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*    Press 1 to open calculator;      *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* press 2 to open polygon calculation *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*      Press 3 to open MiniGame       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*       this app created by Ali       *").pack()
label = Label(root, text ="*     Khodaverdi and Vesal Vafaee     *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
entekhab = Entry (window) 
entekhab.pack()

من تازه کارم اگر میشه لطفا کمک کنید


ثبت پرسش جدید
mmj-sys
تخصص : داش متخصص چیه من پروفسورم .
@mmj.sys 2 سال پیش مطرح شد
0

کد کامل رو قرار بدید من فایلو اجرا کنم که ببینم مشکل از کجاست اینجوری بدون اجرا نمیتونم کمکی کنم


وصال وفایی
تخصص : برنامه نویس
@cp.Vesal 2 سال پیش مطرح شد
0

@mmj.sys
متن کامل

import tkinter
from turtle import *
from sys import *
from time import *
from tkinter import *
def btnClick(numbers):
    global operator
    operator = operator + str(numbers)
    text_input.set(operator)
def btnClearDisplay():
    global operator
    operator =""
    text_input.set("")
def btnEqualsInput():
    global operator
    sumup = str(eval(operator))
    text_input.set(sumup)
    operator=""
cal = Tk()
cal.title("Vesal Calculator")
operator = ""
text_input = StringVar()
window = tkinter.Tk()
root = Tk()
window.configure(bg="WHITE", height='300px ', width='300px', cursor="wait")               
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*     Welcome to this programm;       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*    Press 1 to open calculator;      *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* press 2 to open polygon calculation *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*      Press 3 to open MiniGame       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*       this app created by Ali       *").pack()
label = Label(root, text ="*     Khodaverdi and Vesal Vafaee     *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
entekhab = Entry (window) 
entekhab.pack()

def one():
    b = int(input("Enter the number of sides : "))
    while b < 3:
        b = int(input("Eror . please enter correct number : "))
        print("")
        n = (b-2)*180
        print("informations : ")
        print("")
        print("    • sum of angles : ", n ,"°")
        print("")
        print("    • The value of each angle : ", n//b , "°")
        print("")
        o = input("Do you want to countinue again?(y/n) ")
        print("")

def two():
    g = int(input("Enter the number of sides : "))
    while g<3:
        g = int(input("EROR!!please enter correct number : "))
    m = g-3
    j = m*g//2
    print("number of diameters : " , j)

print("")
answer = int(input("Enter a number : "))

if answer == 1:
    def btnClick(numbers):
        global operator
        operator = operator + str(numbers)
        text_input.set(operator)
    def btnClearDisplay():
        global operator
        operator =""
        text_input.set("")
    def btnEqualsInput():
        global operator
        sumup = str(eval(operator))
        text_input.set(sumup)
        operator=""
    cal = Tk()
    cal.title("Vesal Calculator")
    operator = ""
    text_input = StringVar()
    txtDisplay = Entry(cal, font=('arial', 20, 'bold'), textvariable=text_input, bd=30,
                    insertwidth=4, bg='powder blue', justify='right').grid(columnspan=4)
    btn7 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='7', command=lambda:btnClick(7) ).grid(row=1, column=0)
    btn8 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='8', command=lambda:btnClick(8)).grid(row=1, column=1)
    btn9 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='9', command=lambda:btnClick(9)).grid(row=1, column=2)
    addition = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 19, 'bold'),
                text='+', command=lambda:btnClick('+')).grid(row=1, column=3)
    #============================================================================
    btn4 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='4', command=lambda:btnClick(4)).grid(row=2, column=0)
    btn5 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='5', command=lambda:btnClick(5)).grid(row=2, column=1)
    btn6 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='6', command=lambda:btnClick(6)).grid(row=2, column=2)
    subtraction = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='-', command=lambda:btnClick('-')).grid(row=2, column=3)
    #============================================================================
    btn1 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                    text='1', command=lambda:btnClick(1)).grid(row=3, column=0)
    btn2 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='2', command=lambda:btnClick(2)).grid(row=3, column=1)
    btn3 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='3', command=lambda:btnClick(3)).grid(row=3, column=2)
    multiply = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='*', command=lambda:btnClick('*')).grid(row=3, column=3)
    #============================================================================
    btn0 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='0', command=lambda:btnClick(0)).grid(row=4, column=0)
    btnClear = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='C', command= btnClearDisplay).grid(row=4, column=1)
    btnEquals = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='=', command=btnEqualsInput).grid(row=4, column=2)
    division = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='/', command=lambda:btnClick('/')).grid(row=4, column=3)
    cal.mainloop()

if answer == 2:
    print("Welcome to polygon calculation ")
    print("")
    o = "y"
    while o == "y":
        print("Enter 1 to angles calculation ")
        print("Enter 2 to diameters calculation")
        a = int(input("Enter a number : "))
        print("")
        if a == 1 :
            one()  
            if o == "n":
                s = input("Do you want to go to Home??(y,n) ")
                if s == "n":
                    print("")
                    print("Ok . Goodbye ; Have a good time :) ")
                    sleep(1)
                    exit()
                    #elif o == "y":

        elif a == 2 :
            two()
            z = input("Do you want to countinue again?(y,n) ")
            if z == "n":
                l = input("Do you want go to home?(y/n) ")
            if l == "n":
                print("Ok . Goodbye ; Have a good time :) ")
                sleep(1)
                exit()

if answer == 3:
    print("Welcome to 'guess the numbers game'")
    print("")
    print("guess a number between 1 and 40 ; you have 6 chances")
    sleep(0.5)
    cn = randint(1,40)
    chance = 6
    for i in range(6):
        un = int(input("please enter number : "))
        print("")
        if un > cn:
            print("your number is bigger!!")
        elif un < cn:
            print("your number is smaller!!")
        else:
            print("congratulations !! your number is correct!!You are winer :D")
            break
        chance = chance-1
        print("you have " , chance , " chance")
    if chance == 0:
        print("sorry!!you are loser!computer number is : " , cn)

print("")
op = int(input("Do you want to play again?(y/n)"))
if op == "n":
    sp = int(input("Do you want go to home?(y/n)"))
    if sp == "n":
        print("")
        print("Ok . Goodbye ; Have a good time :) ")
        sleep(1)
        exit()

elif op == "y":
    print("Welcome to 'guess the numbers game'")
    print("")
    print("guess a number between 1 and 40 ; you have 6 chances")
    sleep(0.5)
    cn = randint(1,40)
    chance = 6
    for i in range(6):
        un = int(input("please enter number : "))
        print("")
        if un > cn:
            print("your number is bigger!!")
        elif un < cn:
            print("your number is smaller!!")
        else:
            print("congratulations !! your number is correct!!You are winer :D")
            break
        chance = chance-1
        print("you have " , chance , " chance")
    if chance == 0:
        print("sorry!!you are loser!computer number is : " , cn)

mmj-sys
تخصص : داش متخصص چیه من پروفسورم .
@mmj.sys 2 سال پیش مطرح شد
0

شما امدی یک بار کل ماژول های tkinter رو فرا خوانی کردی و یک بار خودشو بعد سه بار با نام های cal , window , root بهشون مقدار دادی

من اونا رو برداشتم و فکر کنم هدف این بوده که یک پاپ اپ درست کنید و ورودی هاتونو بگیرید
من گزاشتمشون تو یک تابع همون اول و شما به همونا گرید بده تا نمایش داده بشن نیازی به پک کردن ندارن خودش انجام میده فقط شما باید استایل بدی

from turtle import *
from sys import *
from time import *
from tkinter import *
def messageWindow():
    win = Toplevel()
    win.geometry('300x200')

    root.withdraw() # THIS HIDE THE WINDOW
    intput = Entry(win)
    label = Label(win, text="This is a label")
    Button(win, text='OK', command=win.destroy)

def btnClick(numbers):
    global operator
    operator = operator + str(numbers)
    text_input.set(operator)
def btnClearDisplay():
    global operator
    operator =""
    text_input.set("")
def btnEqualsInput():
    global operator
    sumup = str(eval(operator))
    text_input.set(sumup)
    operator=""
operator = ""
root = Tk()
root.title("line 21")
root.configure(bg="WHITE", height='300px ', width='300px')               
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*     Welcome to this programm;       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*    Press 1 to open calculator;      *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* press 2 to open polygon calculation *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*      Press 3 to open MiniGame       *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="*       this app created by Ali       *").pack()
label = Label(root, text ="*     Khodaverdi and Vesal Vafaee     *").pack()
label = Label(root, text ="*                                     *").pack()
label = Label(root, text ="* * * * * * * * * * * * * * * * * * * *").pack()
messageWindow()

def one():
    b = int(input("Enter the number of sides : "))
    while b < 3:
        b = int(input("Eror . please enter correct number : "))
        print("")
        n = (b-2)*180
        print("informations : ")
        print("")
        print("    • sum of angles : ", n ,"°")
        print("")
        print("    • The value of each angle : ", n//b , "°")
        print("")
        o = input("Do you want to countinue again?(y/n) ")
        print("")

def two():
    g = int(input("Enter the number of sides : "))
    while g<3:
        g = int(input("EROR!!please enter correct number : "))
    m = g-3
    j = m*g//2
    print("number of diameters : " , j)

print("")
answer = int(input("Enter a number : "))

if answer == 1:
    def btnClick(numbers):
        global operator
        operator = operator + str(numbers)
        text_input.set(operator)
    def btnClearDisplay():
        global operator
        operator =""
        text_input.set("")
    def btnEqualsInput():
        global operator
        sumup = str(eval(operator))
        text_input.set(sumup)
        operator=""
    cal = Tk()
    cal.title("Vesal Calculator")
    operator = ""
    text_input = StringVar()
    txtDisplay = Entry(cal, font=('arial', 20, 'bold'), textvariable=text_input, bd=30,
                    insertwidth=4, bg='powder blue', justify='right').grid(columnspan=4)
    btn7 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='7', command=lambda:btnClick(7) ).grid(row=1, column=0)
    btn8 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='8', command=lambda:btnClick(8)).grid(row=1, column=1)
    btn9 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='9', command=lambda:btnClick(9)).grid(row=1, column=2)
    addition = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 19, 'bold'),
                text='+', command=lambda:btnClick('+')).grid(row=1, column=3)
    #============================================================================
    btn4 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='4', command=lambda:btnClick(4)).grid(row=2, column=0)
    btn5 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='5', command=lambda:btnClick(5)).grid(row=2, column=1)
    btn6 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='6', command=lambda:btnClick(6)).grid(row=2, column=2)
    subtraction = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='-', command=lambda:btnClick('-')).grid(row=2, column=3)
    #============================================================================
    btn1 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                    text='1', command=lambda:btnClick(1)).grid(row=3, column=0)
    btn2 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='2', command=lambda:btnClick(2)).grid(row=3, column=1)
    btn3 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='3', command=lambda:btnClick(3)).grid(row=3, column=2)
    multiply = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='*', command=lambda:btnClick('*')).grid(row=3, column=3)
    #============================================================================
    btn0 = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='0', command=lambda:btnClick(0)).grid(row=4, column=0)
    btnClear = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='C', command= btnClearDisplay).grid(row=4, column=1)
    btnEquals = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='=', command=btnEqualsInput).grid(row=4, column=2)
    division = Button(cal, padx=16, pady=16, bd=8, fg='black', font=('arial', 20, 'bold'),
                text='/', command=lambda:btnClick('/')).grid(row=4, column=3)
    cal.mainloop()

if answer == 2:
    print("Welcome to polygon calculation ")
    print("")
    o = "y"
    while o == "y":
        print("Enter 1 to angles calculation ")
        print("Enter 2 to diameters calculation")
        a = int(input("Enter a number : "))
        print("")
        if a == 1 :
            one()  
            if o == "n":
                s = input("Do you want to go to Home??(y,n) ")
                if s == "n":
                    print("")
                    print("Ok . Goodbye ; Have a good time :) ")
                    sleep(1)
                    exit()
                    #elif o == "y":

        elif a == 2 :
            two()
            z = input("Do you want to countinue again?(y,n) ")
            if z == "n":
                l = input("Do you want go to home?(y/n) ")
            if l == "n":
                print("Ok . Goodbye ; Have a good time :) ")
                sleep(1)
                exit()

if answer == 3:
    print("Welcome to 'guess the numbers game'")
    print("")
    print("guess a number between 1 and 40 ; you have 6 chances")
    sleep(0.5)
    cn = randint(1,40)
    chance = 6
    for i in range(6):
        un = int(input("please enter number : "))
        print("")
        if un > cn:
            print("your number is bigger!!")
        elif un < cn:
            print("your number is smaller!!")
        else:
            print("congratulations !! your number is correct!!You are winer :D")
            break
        chance = chance-1
        print("you have " , chance , " chance")
    if chance == 0:
        print("sorry!!you are loser!computer number is : " , cn)

print("")
op = int(input("Do you want to play again?(y/n)"))
if op == "n":
    sp = int(input("Do you want go to home?(y/n)"))
    if sp == "n":
        print("")
        print("Ok . Goodbye ; Have a good time :) ")
        sleep(1)
        exit()

elif op == "y":
    print("Welcome to 'guess the numbers game'")
    print("")
    print("guess a number between 1 and 40 ; you have 6 chances")
    sleep(0.5)
    cn = randint(1,40)
    chance = 6
    for i in range(6):
        un = int(input("please enter number : "))
        print("")
        if un > cn:
            print("your number is bigger!!")
        elif un < cn:
            print("your number is smaller!!")
        else:
            print("congratulations !! your number is correct!!You are winer :D")
            break
        chance = chance-1
        print("you have " , chance , " chance")
    if chance == 0:
        print("sorry!!you are loser!computer number is : " , cn)

وصال وفایی
تخصص : برنامه نویس
@cp.Vesal 2 سال پیش آپدیت شد
0

@mmj.sys
دستتون طلا
درست شد


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام