Найти - Пользователи
Полная версия: Использование модулей
Начало » Python для новичков » Использование модулей
1
E_off
Привет!
Нужна помощь,создаю маленькую программу ‘тестирования’,нужно функцией clean очищать не только выбранные варианты ответов, но и удалить или изменить, модуль lb3, который появляется, если не выбрать вариант ответа.Как это сделать?Сложность в том, что я не знаю как взаимодействовать с модулем, созданным в другой функции

Зарание спасибо!

 from tkinter import *
from tkinter import ttk
root=Tk()
root.title('Кнопки')
root.geometry('400x300')
score=0
def clean():
  rad1.deselect()
  rad2.deselect()
  rad3.deselect()
  check1.deselect()
  check2.deselect()
  check3.deselect()
def prov():
  global score
  score=0
  if all_var.get()!=1 and all_var.get()!=2 and all_var.get()!=3:
    r_chek=Label(root,text=f'Choose one of the options!',fg='red')
    r_chek.place(x=45,y=35)
  elif all_var.get()==2:
    score+=1 
  else:
    pass
  score+=int(c2.get())+int(c3.get())
  lb3=Label(root,text=f'You have {score} point(-s)')
  lb3.place(x=145,y=260)
  
c=Canvas(root,width=600,height=800,bg='black')
lb1=Label(root,text='1.Result of the operation print("a"*10)',justify='center')
lb1.place(x=45,y=15)
all_var=IntVar()
c1=IntVar()
c2=IntVar()
c3=IntVar()
rad1=Radiobutton(root,text='10a',variable=all_var,command='text',value=1)
rad2=Radiobutton(root,text='aaaaaaaaaa',variable=all_var,command='text2',value=2)
rad3=Radiobutton(root,text='Error',variable=all_var,command='text3',value=3)
rad1.place(x=20,y=50)
rad2.place(x=20,y=70)
rad3.place(x=20,y=90)
lb2=Label(root,text='2.Allowed python variable names',justify='center')
lb2.place(x=45,y=130)
check1=Checkbutton(root,text="2b",variable=c1,onvalue="1",offvalue='0')
check2=Checkbutton(root,text='_d3',variable=c2,onvalue="1",offvalue='0')
check3=Checkbutton(root,text='frs',variable=c3,onvalue="1",offvalue='0')
check1.place(x=20,y=165)
check2.place(x=20,y=185)
check3.place(x=20,y=205)
btn=Button(root,text='Check out',command=prov,width=6)
btn.place(x=90,y=225)
btn2=Button(root,text='Clean',command=clean,width=6)
btn2.place(x=220,y=225)
c.place()
root.mainloop()
py.user.next
E_off
Как это сделать?Сложность в том, что я не знаю как взаимодействовать с модулем, созданным в другой функции
Создай его там, где все другие элементы создаёшь. А в функции потом просто меняй его состояние (значения в нём).
E_off
py.user.next
Создай его там, где все другие элементы создаёшь. А в функции потом просто меняй его состояние (значения в нём).
Привет! Спасибо за помощь! Подскажи пожалуйста как сделать RadioButton как в первом варианте (При запуске программы)
py.user.next
E_off
Подскажи пожалуйста как сделать RadioButton как в первом варианте
Убери везде deselect() и сделай all_var.set(None) .
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB