Python – die besten Beiträge

Wie kann ich button Ausrichten (Python)?

Ich wollte in folgendem Code den Button abstand entfernen, damit diese nicht so eine große lücke haben.

from tkinter import *
import random
from tkinter import messagebox

root = Tk()
root.title('Lock')
root.geometry('400x780')

one_btn = Button(root, text='1', command=one_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
two_btn = Button(root, text='2', command=two_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
three_btn = Button(root, text='3', command=three_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
four_btn = Button(root, text='4', command=four_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
five_btn = Button(root, text='5', command=five_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
six_btn = Button(root, text='6', command=six_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
seven_btn = Button(root, text='7', command=seven_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
eight_btn = Button(root, text='8', command=eight_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
nine_btn = Button(root, text='9', command=nine_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
plus_btn = Button(root, text='+', command=plus_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
minus_btn = Button(root, text='-', command=minus_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
mult_btn = Button(root, text='*', command=mult_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=10)
div_btn = Button(root, text='/', command=div_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=30)
square_btn = Button(root, text='^', command=square_btn_press, activebackground='#3a3b3c', background='#2a2b2c', fg='#7a7b7c', height='3', width=30)



one_btn.grid(row=0, column=0, pady=0, padx=0)
two_btn.grid(row=0, column=1, pady=0, padx=0)
three_btn.grid(row=0, column=2, pady=0, padx=0)
four_btn.grid(row=1, column=0, pady=0, padx=0)
five_btn.grid(row=1, column=1, pady=0, padx=0)
six_btn.grid(row=1, column=2, pady=0, padx=0)
seven_btn.grid(row=2, column=0, pady=0, padx=0)
eight_btn.grid(row=2, column=1, pady=0, padx=0)
nine_btn.grid(row=2, column=2, pady=0, padx=0)
plus_btn.grid(row=0, column=3, pady=0, padx=0)
minus_btn.grid(row=1, column=3, pady=0, padx=0)
mult_btn.grid(row=2, column=3, pady=0, padx=0)
div_btn.grid(row=3, column=1, pady=0, padx=0)
square_btn.grid(row=3, column=2, pady=0, padx=0)


root.call('wm', 'attributes', '.', '-topmost', '1')
root.mainloop()
programmieren, Python

Chrome Driver | Python | Ubuntu?

Hey,

wenn ich versuche den Chromedriver mit Selenium und Python zu starten bekomme ich den Fehler:

[WDM] - ====== WebDriver manager ======
[WDM] - Current google-chrome version is 102.0.5005
[WDM] - Get LATEST chromedriver version for 102.0.5005 google-chrome
[WDM] - Driver [/root/.wdm/drivers/chromedriver/linux64/102.0.5005.61/chromedriver] found in cache
test2.py:41: DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(chrome_options=options, service=Service(ChromeDriverManager().install()))
Traceback (most recent call last):
  File "test2.py", line 117, in <module>
    webscraperopen()
  File "test2.py", line 41, in webscraperopen
    driver = webdriver.Chrome(chrome_options=options, service=Service(ChromeDriverManager().install()))
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
    RemoteWebDriver.__init__(
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 275, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 365, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Linux, Python

Meistgelesene Beiträge zum Thema Python