Tkinter - Python help please! !!URGENT!!

ralbhat

Disciple
Hey,

I need help with a python Tkinter code piece. Basically, the program isn't quitting. It works fine, encryption and all are happening, but the QUIT button doesn't work, and new windows keep opening up. Can someone help?

When the user clicks either "encrypt" or "decrypt", the program should go back to the first window that comes up (delete the second window or something?!) and when the user clicks "quit", the program should end.

The various imports in the starting are my own .py files (compiled).

I'm just using 4 of them yet.. want them to work before I integrate all 8.

HELP!!!:huh::huh::huh:

Code:
import my_encryptor

import my_decryptor

import lzw_encryptor

import lzw_decryptor

import vig_encryptor

import vig_decryptor

import rsa_encryptor

from Tkinter import *

class sel1:

    def __init__(self,parent):

        frame = Frame(parent)

        frame.pack()

        self.Cust1 = Button(frame,text="Custom Algorithm 1",command=self.selcust1)

        self.Cust2 = Button(frame,text="Vigenere Cypher",command=self.selvig)

        self.Cust1.pack(side=TOP)

        self.Cust2.pack()

        self.but = Button(frame,text="Quit",fg="red",command=frame.quit)

        self.but.pack(side=BOTTOM)

    def selcust1(self):

        self.new = Toplevel()

        frame2=Frame(self.new)

        frame2.pack()

        self.enc = Button(frame2,text="Encrypt",command=self.selcust1enc)

        self.dec = Button(frame2,text="Decrypt",command=self.selcust1dec)

        self.enc.pack(side=LEFT)

        self.dec.pack(side=RIGHT)

    def selvig(self):

        self.new = Toplevel()

        frame2=Frame(self.new)

        frame2.pack()

        self.enc = Button(frame2,text="Encrypt",command=self.selvigenc)

        self.dec = Button(frame2,text="Decrypt",command=self.selvigdec)

        self.enc.pack(side=LEFT)

        self.dec.pack(side=RIGHT)

    def selcust1enc(self):

        self.new.quit()

        my_encryptor.my_encryptor("abc.txt","a.txt")

    def selcust1dec(self):

        self.new.quit()

        my_decryptor.my_decryptor("a.txt","b.txt")

            

root = Tk()

prog = sel1(root)

root.mainloop()
 
Hold on... I will have to start with Tkinter first, let me check that.

Ok, how about this:
Code:
import my_encryptor
import my_decryptor
import lzw_encryptor
import lzw_decryptor
import vig_encryptor
import vig_decryptor
import rsa_encryptor
from Tkinter import *

class sel1(Frame):
    def __init__(self,parent = None):
        Frame.__init__(self, parent)
        self.pack()
        self.Cust1 = Button(self,text="Custom Algorithm 1",command=self.selcust1)
        self.Cust2 = Button(self,text="Vigenere Cypher",command=self.selvig)
        self.Cust1.pack(side=TOP)
        self.Cust2.pack()
        self.but = Button(self,text="Quit",fg="red",command=self.quit)
        self.but.pack(side=BOTTOM)
    def selcust1(self):
        self.new = Toplevel()
        frame2=Frame(self.new)
        frame2.pack()
        self.enc = Button(frame2,text="Encrypt",command=self.selcust1enc)
        self.dec = Button(frame2,text="Decrypt",command=self.selcust1dec)
        self.enc.pack(side=LEFT)
        self.dec.pack(side=RIGHT)
    def selvig(self):
        self.new = Toplevel()
        frame2=Frame(self.new)
        frame2.pack()
        self.enc = Button(frame2,text="Encrypt",command=self.selvigenc)
        self.dec = Button(frame2,text="Decrypt",command=self.selvigdec)
        self.enc.pack(side=LEFT)
        self.dec.pack(side=RIGHT)
    def selcust1enc(self):
        self.new.quit()
        my_encryptor.my_encryptor("abc.txt","a.txt")
    def selcust1dec(self):
        self.new.quit()
        my_decryptor.my_decryptor("a.txt","b.txt")
            
#oc = 'y'
#while oc=='y':
root = Tk()
prog = sel1(root)
prog.mainloop()
root.destroy()

+LT
 
Hmmmm..
Thanks! I was actually transforming from the non GUI to GUI version.. missed out that while loop :S:S

And the destroy statement.. new :p
Thanks!:hap2::hap2:
 
ralbhat said:
Hmmmm..
Thanks! I was actually transforming from the non GUI to GUI version.. missed out that while loop :S:S

And the destroy statement.. new :p
Thanks!:hap2::hap2:

May I recommend: Refer the user guide... :D
+LT
 
Back
Top