Код: Выделить всё
font_name = style.get("font_name", UIFlatButton.UIStyle.font_name)
^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Код: Выделить всё
#Module importieren
import arcade
import arcade.gui
import arcade.gui.widgets.buttons
import arcade.gui.widgets.layout
from arcade.gui import UIFlatButton
#Variablen definieren
width = 1200
height = 800
title = "Black Jack Arcade"
button_words = ["Hit", "Stand", "Split", "Double Down"]
border_color = arcade.color.ZINNWALDITE_BROWN
# Constants for sizing
CARD_SCALE = 0.6
# How big are the cards?
CARD_WIDTH = 140 * CARD_SCALE
CARD_HEIGHT = 190 * CARD_SCALE
# How big is the mat we'll place the card on?
MAT_PERCENT_OVERSIZE = 1.25
MAT_HEIGHT = int(CARD_HEIGHT * MAT_PERCENT_OVERSIZE)
MAT_WIDTH = int(CARD_WIDTH * MAT_PERCENT_OVERSIZE)
# How much space do we leave as a gap between the mats?
# Done as a percent of the mat size.
VERTICAL_MARGIN_PERCENT = 0.10
HORIZONTAL_MARGIN_PERCENT = 0.10
# The Y of the bottom row (2 piles)
BOTTOM_Y = MAT_HEIGHT / 2 + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# The X of where to start putting things on the left side
START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
# Card constants
CARD_VALUES = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
CARD_SUITS = ["Kreuz", "Herz", "Pik", "Karo"]
#klassen erstellen
class graphic(arcade.Window):
def __init__(self):
super().__init__(width, height, title)
#Initialisierung anderer Module
self.ui = arcade.gui.UIManager()
self.ui.enable()
#startet die Buttons
self.create_click()
arcade.set_background_color(arcade.color.AO)
# Hier werden alle externen Texturen geladen und eingesetzt
def load_textures(self):
# create wooden background
wood_back = arcade.load_texture("/Users/maximilianstriegler/Desktop/Golden Black Jack/game_textures/background_wood.jpg")
arcade.draw_lbwh_rectangle_textured(0, 0, 1200, 800, wood_back)
# create green felt texture
playing_field = arcade.load_texture("/Users/maximilianstriegler/Desktop/Golden Black Jack/game_textures/background_felt.jpg")
arcade.draw_lbwh_rectangle_textured(250, 50, 900, 700, playing_field)
arcade.draw_rectangle_outline(700, 400, 900, 700, border_color, 3)
# Funktion um Knöpfe zu erstellen
def create_button(self, x, y, width, height, color, border_width):
arcade.draw_xywh_rectangle_filled(x - width / 2, y - height / 2, width, height, color)
arcade.draw_rectangle_outline(x, y, width, height, border_color, border_width)
def create_click(self):
button_style = {
"big" : UIFlatButton.UIStyle(
font_size=20,
font_name=('calibri', 'arial'),
font_color=arcade.color.RED,
bg=arcade.color.BLUE,
border=arcade.color.BLUE,
border_width=2,
)
}
#create buttons
for i in range(len(button_words)):
buttons = arcade.gui.UIFlatButton(text=button_words[i], x=30, y=630 - (i * 150), width=190, height=100,
style=button_style)
buttons.on_click = self.on_click_button
self.ui.add(buttons)
exit_button = arcade.gui.UIFlatButton(text= "Exit", x= 77.5, y= 70, width= 95, height=50)
exit_button.on_click = self.on_exit_quit
self.ui.add(exit_button)
#Funktion große Buttons
def on_click_button(self, event):
print("JAAAAA")
#Funktion Exit Button
def on_exit_quit(self, event):
print("Exit Button Clicked")
def on_draw(self):
#Rendern starten
arcade.start_render()
#Texturen laden
self.load_textures()
#Buttons laden
self.ui.draw()
#Rendern beenden
arcade.finish_render()
def start():
window = graphic()
arcade.run()
if __name__ == "__main__":
start()
Подробнее здесь: https://stackoverflow.com/questions/785 ... led-button