ParthJadhav / Tkinter-Designer

An easy and fast way to create a Python GUI 🐍
BSD 3-Clause "New" or "Revised" License
8.87k stars 817 forks source link

Blank Screen and haven't pic problem,hele me #207

Closed SaltNego closed 2 years ago

SaltNego commented 2 years ago

当我用工具下载下来后运行发现是黑色的, 而且我添加的图片也没有,求教大佬

`# This file was generated by the Tkinter Designer by Parth Jadhav

https://github.com/ParthJadhav/Tkinter-Designer

coding:utf-8

from pathlib import Path

from tkinter import *

Explicit imports to satisfy Flake8

from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage

OUTPUT_PATH = Path(file).parent ASSETS_PATH = OUTPUT_PATH / Path("./assets")

def relative_to_assets(path: str) -> Path: return ASSETS_PATH / Path(path)

window = Tk()

window.geometry("950x585") window.configure(bg="#FFFFFF")

canvas = Canvas( window, bg="#FFFFFF", height=585, width=950, bd=0, highlightthickness=0, relief="ridge" )

canvas.place(x=0, y=0) canvas.create_rectangle( 61.0, 33.0, 450.0, 533.0, fill="#000000", outline="")

canvas.create_rectangle( 474.0, 200.0, 724.0, 248.0, fill="#000000", outline="")

canvas.create_rectangle( 748.0, 202.0, 881.0, 248.0, fill="#000000", outline="")

canvas.create_rectangle( 475.0, 391.0, 665.0, 477.0, fill="#000000", outline="")

canvas.create_rectangle( 691.0, 391.0, 881.0, 477.0, fill="#000000", outline="")

canvas.create_text( 481.0, 177.0, anchor="nw", text="请选择需要转换的文件:\n", fill="#000000", font=("Inter", 12 * -1) )

canvas.create_rectangle( 799.0, 205.0, 855.0, 240.0, fill="#000000", outline="")

canvas.create_text( 531.0, 422.0, anchor="nw", text="转换", fill="#000000", font=("Inter", 12 * -1) )

canvas.create_text( 746.0, 423.0, anchor="nw", text="关闭", fill="#000000", font=("Inter", 12 * -1) )

canvas.create_rectangle( 551.0, 41.0, 660.0, 133.0, fill="#000000", outline="")

canvas.create_rectangle( 660.0, 41.0, 769.0, 133.0, fill="#000000", outline="") window.resizable(False, False) window.mainloop() `

SaltNego commented 2 years ago
# This file was generated by the Tkinter Designer by Parth Jadhav
# https://github.com/ParthJadhav/Tkinter-Designer
# coding:utf-8
from pathlib import Path

# from tkinter import *
# Explicit imports to satisfy Flake8
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage

OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("./assets")

def relative_to_assets(path: str) -> Path:
    return ASSETS_PATH / Path(path)

window = Tk()

window.geometry("950x585")
window.configure(bg="#FFFFFF")

canvas = Canvas(
    window,
    bg="#FFFFFF",
    height=585,
    width=950,
    bd=0,
    highlightthickness=0,
    relief="ridge"
)

canvas.place(x=0, y=0)
canvas.create_rectangle(
    61.0,
    33.0,
    450.0,
    533.0,
    fill="#000000",
    outline="")

canvas.create_rectangle(
    474.0,
    200.0,
    724.0,
    248.0,
    fill="#000000",
    outline="")

canvas.create_rectangle(
    748.0,
    202.0,
    881.0,
    248.0,
    fill="#000000",
    outline="")

canvas.create_rectangle(
    475.0,
    391.0,
    665.0,
    477.0,
    fill="#000000",
    outline="")

canvas.create_rectangle(
    691.0,
    391.0,
    881.0,
    477.0,
    fill="#000000",
    outline="")

canvas.create_text(
    481.0,
    177.0,
    anchor="nw",
    text="请选择需要转换的文件:\n",
    fill="#000000",
    font=("Inter", 12 * -1)
)

canvas.create_rectangle(
    799.0,
    205.0,
    855.0,
    240.0,
    fill="#000000",
    outline="")

canvas.create_text(
    531.0,
    422.0,
    anchor="nw",
    text="转换",
    fill="#000000",
    font=("Inter", 12 * -1)
)

canvas.create_text(
    746.0,
    423.0,
    anchor="nw",
    text="关闭",
    fill="#000000",
    font=("Inter", 12 * -1)
)

canvas.create_rectangle(
    551.0,
    41.0,
    660.0,
    133.0,
    fill="#000000",
    outline="")

canvas.create_rectangle(
    660.0,
    41.0,
    769.0,
    133.0,
    fill="#000000",
    outline="")
window.resizable(False, False)
window.mainloop()
avivfaraj commented 2 years ago

For some reason the color is automatically set to black. You can see fill="#000000" in every instance of canvas.create_rectangle. I had the same issue, but it is very easy to fix, just change fill to another color say: fill="#707070" and you should see it turns gray.

For the image issue, try: josav09- stackoverflow, he published a code to upload an image as a label in Tkinter.