minor cleanup
This commit is contained in:
parent
be55cc5432
commit
c28d1be0f5
10
data.py
10
data.py
|
|
@ -56,23 +56,15 @@ def open_db(filename=FILENAME):
|
||||||
|
|
||||||
|
|
||||||
def main(filename):
|
def main(filename):
|
||||||
print('Initializing db file', filename)
|
|
||||||
conn = initialize_db_tables(filename)
|
conn = initialize_db_tables(filename)
|
||||||
stars.init_db(conn)
|
stars.init_db(conn)
|
||||||
|
|
||||||
|
|
||||||
##def stars():
|
|
||||||
## global conn
|
|
||||||
## c = conn.cursor()
|
|
||||||
## c.execute('select x, y, radius from stars')
|
|
||||||
## yield from c.fetchall()
|
|
||||||
## c.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
if not pathlib.Path(FILENAME).exists():
|
if not pathlib.Path(FILENAME).exists():
|
||||||
|
print('Initializing db file', FILENAME)
|
||||||
main(FILENAME)
|
main(FILENAME)
|
||||||
else:
|
else:
|
||||||
print(FILENAME, 'already exists! Not overwriting.')
|
print(FILENAME, 'already exists! Not overwriting.')
|
||||||
|
|
|
||||||
23
ui.py
23
ui.py
|
|
@ -19,6 +19,7 @@
|
||||||
# along with game. If not see <http://www.gnu.org/licenses/>.
|
# along with game. If not see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Notebook
|
||||||
|
|
||||||
import data, stars
|
import data, stars
|
||||||
|
|
||||||
|
|
@ -29,32 +30,32 @@ class App:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, master=None, *canvas_args, **canvas_kw):
|
def __init__(self, master=None, *canvas_args, **canvas_kw):
|
||||||
frame = self.frame = Frame(root, bg='green')
|
frame = self.frame = Frame(root, background='green')
|
||||||
frame.rowconfigure(0, weight=1)
|
frame.rowconfigure(0, weight=1)
|
||||||
frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(0, weight=1)
|
||||||
frame.pack(expand=True, fill=BOTH)
|
frame.pack(expand=True, fill=BOTH)
|
||||||
|
|
||||||
C = self.canvas = Canvas(frame, *canvas_args, **canvas_kw)
|
canvas = self.canvas = Canvas(frame, *canvas_args, **canvas_kw)
|
||||||
|
|
||||||
scrollY = self.scrollY = Scrollbar(
|
scrollY = self.scrollY = Scrollbar(
|
||||||
frame,
|
frame,
|
||||||
orient=VERTICAL,
|
orient=VERTICAL,
|
||||||
command=C.yview,
|
command=canvas.yview,
|
||||||
)
|
)
|
||||||
C['yscrollcommand'] = scrollY.set
|
canvas['yscrollcommand'] = scrollY.set
|
||||||
|
|
||||||
scrollX = self.scrollX = Scrollbar(
|
scrollX = self.scrollX = Scrollbar(
|
||||||
frame,
|
frame,
|
||||||
orient=HORIZONTAL,
|
orient=HORIZONTAL,
|
||||||
command=C.xview,
|
command=canvas.xview,
|
||||||
)
|
)
|
||||||
C['xscrollcommand'] = scrollX.set
|
canvas['xscrollcommand'] = scrollX.set
|
||||||
|
|
||||||
C.grid(row=0, column=0, sticky=N+S+E+W)
|
canvas.grid(row=0, column=0, sticky=N+S+E+W)
|
||||||
scrollY.grid(row=0, column=1, sticky=N+S)
|
scrollY.grid(row=0, column=1, sticky=N+S)
|
||||||
scrollX.grid(row=1, column=0, sticky=E+W)
|
scrollX.grid(row=1, column=0, sticky=E+W)
|
||||||
|
|
||||||
C.bind("<Configure>", self.handle_canvas_resize)
|
canvas.bind("<Configure>", self.handle_canvas_resize)
|
||||||
|
|
||||||
def handle_canvas_resize(self, event):
|
def handle_canvas_resize(self, event):
|
||||||
print(event)
|
print(event)
|
||||||
|
|
@ -75,7 +76,7 @@ for x, y, radius in stars.iter_stars(data.conn):
|
||||||
activeoutline='orange',
|
activeoutline='orange',
|
||||||
activewidth=3,
|
activewidth=3,
|
||||||
)
|
)
|
||||||
app.canvas.tag_bind(star_id, '<Enter>', (lambda event, sid=star_id, x=x, y=y: root.title(f'{x}, {y}')))
|
app.canvas.tag_bind(star_id, '<Enter>', (lambda event, x=x, y=y: root.title(f'{x}, {y}')))
|
||||||
|
|
||||||
app.frame.mainloop()
|
##app.frame.mainloop()
|
||||||
data.close_db()
|
##data.close_db()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue