Try to search your question here, if you can't find : Ask Any Question Now ?

how to fix borders please

HomeCategory: stackoverflowhow to fix borders please
Avatarjohn asked 3 months ago

i did this mini programme to show databases to the user , i can see buttons of databases but when i press on them borders appear on canvas

from tkinter import *

from tkinter import ttk


import mysql.connector



class mainpro():

def __init__(self):#its my database settings

    self.db = mysql.connector.connect(
        host="localhost",
        user="root",
        port=3306,
        passwd="1234"
    )
    self.mycursor = self.db.cursor()

    win2 = Toplevel()#idid top level because i did  tk before 
    # Title
    win2.title('Manipulate Database')
    # geometry
    sizex = 1000
    sizey = 700
    posx = 100
    posy = 100
    win2.wm_geometry("%dx%d+%d+%d" % (sizex, sizey, posx, posy))
    # style
    style = ttk.Style()
    style.theme_use('vista')
    style.configure('TLabel', font=('Calibri', 15))
    style.configure('TButton', font=('Calibri', 15, 'bold'))
    # menu
    menu = Menu(win2)
    m1 = Menu(menu, tearoff=0)
    menu.add_cascade(label='File', menu=m1)
    m2 = Menu(menu, tearoff=0)
    menu.add_cascade(label='DLL', menu=m2)
    m3 = Menu(menu, tearoff=0)
    menu.add_cascade(label='DML', menu=m3)
    m4 = Menu(menu, tearoff=0)
    menu.add_cascade(label='Help', menu=m4)

    m1.add_command(label='Show databases', command=lambda: showdata())
    win2.config(menu=menu)

    def showdata():
        def event(event):
            canvas.config(scrollregion=canvas.bbox("all"))

        self.mycursor.execute('SHOW DATABASES')
        list = self.mycursor.fetchall()
        canvas = Canvas(win2, width=1000, height=700)
        f1 = Frame(canvas)
        canvas.create_window((0, 0), window=f1, anchor='nw')
        scroll = Scrollbar(win2, orient="vertical", command=canvas.yview)
        scroll.pack(side="right", fill="y")
        canvas.configure(yscrollcommand=scroll.set)
        canvas.pack()
        f1.bind("<Configure>", event)

        y = 0
        for x in list:
            y += 1
            ttk.Label(f1, text=str(y) + '-').grid(column=0, row=y, padx=10, pady=10, sticky='w')
            ttk.Button(f1, text=x, width=35).grid(column=1, row=y, padx=10, pady=10, sticky='w')

    win2.mainloop()


mainpro()

help please

1 Answers
Best Answer
AvatarMatthias answered 3 months ago
Your Answer

12 + 18 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com