'Why won't Python script run after computer restart?
After a restart my script won't work anymore.
It worked before. Windows popping up, things needed to typed in and there was a result which I was happy with (like v0.9-alpha-happy). Now it yells at me.
import random
import tkinter as tk
from tkinter import simpledialog
from tkinter import messagebox
from tkinter import *
alleSpieler = []
team_eins = []
first_window = tk.Tk
first_window.withdraw()
def main():
global alleSpieler, i, x
i = 1
x = simpledialog.askinteger("Spieleranzahl", "Anzahl der Spieler: ")
if x % 2 == 0:
while i < x + 1:
spieler = simpledialog.askstring("Spielername", "Gib Spielername {} ein: ".format(i))
alleSpieler.append(spieler)
i = i + 1
else:
messagebox.showinfo("Nope", "Bitte gib eine gerade Anzahl von Spielern ein!")
main()
def sec():
j = 1
while j <= len(alleSpieler):
random_name = random.choice(alleSpieler)
team_eins.append(random_name)
alleSpieler.remove(random_name)
j = j + 1
def teams():
root = Tk()
t = Text(root)
for n in team_eins:
t.insert(END,"Team 1: " + n + "\n")
for n in alleSpieler:
t.insert(END,"Team 2: " + n + "\n")
t.pack()
root.mainloop()
main()
sec()
team1()
And the error(s):
/Users/benediktrautenberg/PycharmProjects/TeamGenerator/venv/bin/python /Users/benediktrautenberg/PycharmProjects/TeamGenerator/Generator.py
Traceback (most recent call last):
File "/Users/benediktrautenberg/PycharmProjects/TeamGenerator/Generator.py", line 48, in <module>
main()
File "/Users/benediktrautenberg/PycharmProjects/TeamGenerator/Generator.py", line 17, in main
x = simpledialog.askinteger("Spieleranzahl", "Anzahl der Spieler: ")
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/simpledialog.py", line 343, in askinteger
d = _QueryInteger(title, prompt, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/simpledialog.py", line 271, in __init__
Dialog.__init__(self, parent, title)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/simpledialog.py", line 137, in __init__
if parent.winfo_viewable():
AttributeError: 'NoneType' object has no attribute 'winfo_viewable'
Process finished with exit code 1
Solution 1:[1]
Usually, you would use a single document-store instance per application (singleton).
See the common pattern for initializing the DocumetnStore here:
https://ravendb.net/learn/inside-ravendb-book/reader/4.0/2-zero-to-ravendb#the-document-store
See walkthrough and explanations in this demo:
https://demo.ravendb.net/demos/csharp/basics/the-document-store
Can also follow the example in the Bootcamp repository
https://github.com/ravendb/bootcamp/tree/v5.x/src/unit1/lesson4#exercise-moving-the-documentstore-instance-to-a-singleton-class
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
