是否可以将元素(如Button
)放在彼此相邻的位置,以便在PySimleGUI
中它们之间没有空间
这是我的代码:
import time
import multiprocessing
import PySimpleGUI as sg
def game_window():
game_color = "#82a459"
mana = 10
potion = False
sg.theme('Green')
row1 = [ [sg.Text("z", font="Any 100", text_color=game_color)],
[sg.Text("zzzzzzzzzzz", font="Any 100", text_color=game_color)],
[sg.Text("zzzzzzzzzzz", font="Any 100", text_color=game_color)] ]
row2 = [ [sg.pin(sg.Text(f" {mana} ", key="_text_", font="Any 20"))],
[sg.pin(sg.Button(key="_mana_", image_filename=r"mana256.png", border_width=0.1, button_color=game_color, mouseover_colors=game_color))] ]
row3 = [ [sg.pin(sg.Text("zzzzzzz", font="Any 100", text_color=game_color))] ]
row32 = [ [sg.pin(sg.Text("zzz", font="Any 10", text_color=game_color))] ]
row4 = [ [sg.Button(image_filename=r"plank.png", border_width=0)] ]
row5 = [ [sg.Button(image_filename=r"plank.png", border_width=0, pad=((15,0), (0,0))), sg.Button(image_filename=r"manapotionbuyz.png", key="_manabuy_", border_width=0.1, pad=((15, 0), (0, 0)))] ]
layout = [ [sg.Frame(layout=row1, title="", border_width=0.1), sg.Frame(layout=row2, title="", border_width=0.1, ), sg.Frame(layout=row3, title="", border_width=0.1), sg.Frame(layout=row32, title="", border_width=0.1), sg.Frame(layout=row5, title="", border_width=0.1)] ]
window = sg.Window('Wizard Clash', layout, element_padding=((0, 0), (0, 0)), margins=(0, 0, 0, 0), border_depth=0).finalize()
window.Maximize()
while True:
event, values = window.read(timeout=1000)
if event == sg.WIN_CLOSED or event == 'Cancel':
break
if event == "_mana_":
window["_mana_"].Update(image_filename=r"mana356.png")
mana = mana + 1
time.sleep(0.1)
window["_text_"].Update(f" {mana} ")
window["_mana_"].Update(image_filename=r"mana256.png")
if event == "Ok":
potion = True
mana = mana - 10
window["_text_"].Update(f" {mana} ")
if potion == True:
mana = mana + 2
window["_text_"].Update(f" {mana} ")
window.close()
if __name__ == '__main__':
game_window()
正如您所见,我试图将按钮放在彼此相邻的位置,但它们之间仍然有一个空间:
需要将利润率归零&;填充物
我可以把create blank images in imagemagick当作替身,但这些只是猜测
At the minimum,像素大小对于那些会很好
相关问题 更多 >
编程相关推荐