Home > Blockchain >  Python customtkinter white bar at the top
Python customtkinter white bar at the top

Time:12-24

I am trying to make a gui for my program. It basically uses the steam web api to get data of given game.

I am nearly done with the gui but i see a white bar at the top of my program. I have looked at other posts but no one seems to have this issue.

Any ideas on how to fix it?

I am aware the code is very messy, so i apologize already.

import requests
import customtkinter
from tkinter import *
import tkinter.messagebox
import time
import math

customtkinter.set_appearance_mode("Dark")
customtkinter.set_default_color_theme("blue")


dpiError = False
try:
  from ctypes import windll
  windll.shcore.SetProcessDpiAwareness(1)
except:
  print('ERROR. Could not set DPI awareness.')
  dpiError = True

def runEvent1(arg):
    pass

class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()

        self.title('Steam DLC App')

        if dpiError:
            dpi = 96
        else:
            dpi = self.winfo_fpixels('1i')

        self.geometry(f'{math.ceil(1100 * dpi / 96)}x{math.ceil(660 * dpi / 96)}')
        self.grid_propagate(False)
        for x in range(60):
            Grid.columnconfigure(self, x, weight=1, uniform='row')
            Label(self, width=1).grid(row=0, column=x, sticky=N   S   E   W)
        for y in range(60):
            Grid.rowconfigure(self, y, weight=1, uniform='row')

        self.resizable(False, False)

        gameselected = customtkinter.CTkLabel(self, text="Game Selected:", font=('Helvetica', 14), width=1, height=1)
        gameselected.grid(row=21, column=2, columnspan=20, rowspan=2, sticky=W)

        appid_label = customtkinter.CTkLabel(self, text="AppID:", font=('Helvetica', 14), width=1, height=1)
        appid_label.grid(row=23, column=2, columnspan=20, rowspan=2, sticky=W)

        selected_games_dlcs = customtkinter.CTkLabel(self, text="Selected Games/DLCs", font=('Calibri', 14), width=1, height=1)
        selected_games_dlcs.grid(row=27, column=3, columnspan=53, rowspan=2, sticky=N   S   E   W)

        serial_number = customtkinter.CTkLabel(self, text="#", font=('Calibri', 14), width=1, height=1, bg_color="#2c2e30")
        serial_number.grid(row=31, column=3, columnspan=5, rowspan=2, sticky=N   S   E   W)

        gamedlc_title = customtkinter.CTkLabel(self, text="Game/DLC Title", font=('Calibri', 14), width=1, height=1,bg_color="#2c2e30")
        gamedlc_title.grid(row=31, column=8, columnspan=36, rowspan=2, sticky=N   S   E   W)

        appid_title = customtkinter.CTkLabel(self, text="AppID", font=('Calibri', 14), width=1, height=1,bg_color="#2c2e30")
        appid_title.grid(row=31, column=44, columnspan=12, rowspan=2, sticky=N   S   E   W)

        game_search = customtkinter.CTkLabel(self, text="Game Search", font=('Calibri', 14), width=1, height=1)
        game_search.grid(row=2, column=1, columnspan=24, rowspan=2, sticky=N   S   E   W)

        dlc_search_txt = customtkinter.CTkLabel(self, text="DLC Search", font=('Calibri', 14), width=1, height=1)
        dlc_search_txt.grid(row=2, column=36, columnspan=20, rowspan=2, sticky=N   S   E   W)

        Game_Search = customtkinter.CTkEntry(self, width=1, font=('Helvetica', 12), justify='center')
        Game_Search.grid(row=5, column=2, columnspan=20, rowspan=2, sticky=N   S   E   W)

        DLC_Search = customtkinter.CTkEntry(self, width=1, font=('Helvetica', 12), justify='center')
        DLC_Search.grid(row=5, column=36, columnspan=17, rowspan=2, sticky=N   S   E   W)

        Game_Search.insert(0, "Input Name/AppID")
        DLC_Search.insert(0, "Input Name/AppID")

        search_button = customtkinter.CTkButton(self, text="Go", font=('Arial', 12), width=1, height=1, command=lambda: runEvent1("search_button"), fg_color="#2b0658")
        search_button.grid(row=5, column=23, columnspan=2, rowspan=2, sticky=N   S   E   W)

        go_button = customtkinter.CTkButton(self, text="Go", font=('Arial', 12), width=1, height=1, command=lambda: runEvent1("Button1"), fg_color="#2b0658")
        go_button.grid(row=5, column=54, columnspan=2, rowspan=2, sticky=N   S   E   W)

        add_selected_dlc = customtkinter.CTkButton(self, text="Add Selected DLC(s)", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("add_selected_dlc"), fg_color="#2b0658")
        add_selected_dlc.grid(row=21, column=36, columnspan=8, rowspan=3, sticky=N   S   E   W)

        add_all_dlc = customtkinter.CTkButton(self, text="Add All DLC(s)", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("add_all_dlc"), fg_color="#2b0658")
        add_all_dlc.grid(row=21, column=48, columnspan=8, rowspan=3, sticky=N   S   E   W)

        set_applist_location = customtkinter.CTkButton(self, text="Set Applist Location", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("set_applist_location"), fg_color="#2b0658")
        set_applist_location.grid(row=53, column=3, columnspan=9, rowspan=3, sticky=N   S   E   W)

        save_changes = customtkinter.CTkButton(self, text="Save Changes", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("save_changes"), fg_color="#2b0658")
        save_changes.grid(row=53, column=46, columnspan=10, rowspan=3, sticky=N   S   E   W)

        remove_selected = customtkinter.CTkButton(self, text="Remove Selected", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("remove_selected"), fg_color="#2b0658")
        remove_selected.grid(row=53, column=20, columnspan=8, rowspan=3, sticky=N   S   E   W)

        clear_list = customtkinter.CTkButton(self, text="Clear List", font=('Helvetica', 12), width=1, height=1, command=lambda: runEvent1("clear_list"), fg_color="#2b0658")
        clear_list.grid(row=53, column=29, columnspan=8, rowspan=3, sticky=N   S   E   W)

        Add_Game = customtkinter.CTkButton(self, text="Add", font=('Arial', 12), width=1, height=1, command=lambda: runEvent1("Add_Game"), fg_color="#2b0658")
        Add_Game.grid(row=21, column=22, columnspan=3, rowspan=4, sticky=N   S   E   W)

        search_results = customtkinter.CTkFrame(self, width=1, height=1, fg_color="#2c2e30", border_color="#494d50", border_width=2)
        search_results.grid(row=9, column=2, columnspan=23, rowspan=11, sticky=N   S   E   W)

        dlc_search_frame = customtkinter.CTkFrame(self, width=1, height=1, fg_color="#2c2e30", border_color="#494d50", border_width=2)
        dlc_search_frame.grid(row=9, column=36, columnspan=20, rowspan=11, sticky=N   S   E   W)

        selected_games_dlcs_frame = customtkinter.CTkFrame(self, width=1, height=1, fg_color="#2c2e30", border_color="#494d50", border_width=2)
        selected_games_dlcs_frame.grid(row=33, column=3, columnspan=53, rowspan=19, sticky=N   S   E   W)



if __name__ == "__main__":
    app = App()
    app.mainloop()

CodePudding user response:

The white bar across the top is the group of empty labels that you are adding to row 0. It doesn't appear that you need them, so I recommend removing them. You can keep the calls to columnconfigure, or you can remove that loop and replace it with a single call to columnconfigure where you pass all of the column numbers as a single argument:

self.columnconfigure(tuple(range(60)), weight=1, uniform='row')

CodePudding user response:

Here is a video explaining how to do it:

https://www.youtube.com/watch?v=s0cpxPSN4k4

And here is a code example from someone else on StackOverflow:

Can I change the title bar in Tkinter?

The function is overrideredirect():

Then you will need to make a title bar from scratch.

I would offer a code solution but I don't know what exactly you are looking for. If you add an image or description of what you are looking for, I may be able to help.

  • Related