mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Rework startup
This commit is contained in:
parent
1ac18cd326
commit
63c9e9851e
1 changed files with 10 additions and 26 deletions
|
@ -35,17 +35,14 @@ __version__ = '1.0'
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
import ColorDB
|
import ColorDB
|
||||||
from Tkinter import *
|
|
||||||
from PyncheWidget import PyncheWidget
|
from PyncheWidget import PyncheWidget
|
||||||
from Switchboard import Switchboard
|
from Switchboard import Switchboard
|
||||||
|
from StripViewer import StripViewer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PROGRAM = sys.argv[0]
|
PROGRAM = sys.argv[0]
|
||||||
|
|
||||||
# Milliseconds between interrupt checks
|
|
||||||
KEEPALIVE_TIMER = 500
|
|
||||||
|
|
||||||
# Default locations of rgb.txt or other textual color database
|
# Default locations of rgb.txt or other textual color database
|
||||||
RGB_TXT = [
|
RGB_TXT = [
|
||||||
# Solaris OpenWindows
|
# Solaris OpenWindows
|
||||||
|
@ -63,21 +60,7 @@ def usage(status, msg=''):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app = None
|
|
||||||
|
|
||||||
def keepalive():
|
|
||||||
# Exercise the Python interpreter regularly so keyboard interrupts get
|
|
||||||
# through.
|
|
||||||
app.tk.createtimerhandler(KEEPALIVE_TIMER, keepalive)
|
|
||||||
|
|
||||||
|
|
||||||
def finished(event=None):
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global app
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(
|
opts, args = getopt.getopt(
|
||||||
sys.argv[1:],
|
sys.argv[1:],
|
||||||
|
@ -109,11 +92,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
raise IOError('No color database file found')
|
raise IOError('No color database file found')
|
||||||
|
|
||||||
app = Tk(className='Pynche')
|
# create the application window decorations
|
||||||
app.protocol('WM_DELETE_WINDOW', finished)
|
app = PyncheWidget(__version__)
|
||||||
app.title('Pynche %s' % __version__)
|
parent = app.parent()
|
||||||
app.iconname('Pynche')
|
|
||||||
app.tk.createtimerhandler(KEEPALIVE_TIMER, keepalive)
|
|
||||||
|
|
||||||
# get triplet for initial color
|
# get triplet for initial color
|
||||||
try:
|
try:
|
||||||
|
@ -130,10 +111,13 @@ def main():
|
||||||
except ColorDB.BadColor:
|
except ColorDB.BadColor:
|
||||||
usage(1, 'Cannot find an initial color to use')
|
usage(1, 'Cannot find an initial color to use')
|
||||||
|
|
||||||
s = Switchboard(app, colordb, red, green, blue)
|
# create all output widgets
|
||||||
|
s = Switchboard()
|
||||||
|
s.add_view(StripViewer(s, parent))
|
||||||
|
s.update_views(red, green, blue)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keepalive()
|
app.start()
|
||||||
app.mainloop()
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue