Implementing Error Catching System
This commit is contained in:
parent
932e44e9c6
commit
f153edc9d5
2 changed files with 156 additions and 146 deletions
|
@ -26,6 +26,9 @@ from project_manager import update_reader
|
|||
from project_manager import pm_installUpdatesLayer
|
||||
from project_manager import pm_settingsLayer
|
||||
|
||||
from troubleshooter import error_notify
|
||||
|
||||
|
||||
# UI modules
|
||||
from UI import UI_testing
|
||||
from UI import UI_color
|
||||
|
@ -146,153 +149,159 @@ def pmdrawing(pmdrawing, main_layer, win):
|
|||
# be used in such an application. But to hell with it. I did the same on the
|
||||
# Blender-Organizer altho with way less cairo. And it works well enought.
|
||||
|
||||
# FPS counter
|
||||
win.fFPS = datetime.datetime.now()
|
||||
win.tFPS = win.fFPS - win.sFPS
|
||||
try:
|
||||
|
||||
if win.current["frame"] % 5 == 0:
|
||||
win.blink = not win.blink # Iterating the blink
|
||||
# FPS counter
|
||||
win.fFPS = datetime.datetime.now()
|
||||
win.tFPS = win.fFPS - win.sFPS
|
||||
|
||||
if win.current["frame"] % 5 == 0:
|
||||
win.blink = not win.blink # Iterating the blink
|
||||
|
||||
|
||||
if win.current["frame"] % 10 == 0:
|
||||
win.FPS = int ( 1.0 / ( win.tFPS.microseconds /1000000))
|
||||
if win.current["frame"] % 10 == 0:
|
||||
win.FPS = int ( 1.0 / ( win.tFPS.microseconds /1000000))
|
||||
|
||||
if "Auto_De-Blur" not in win.settings:
|
||||
win.settings["Auto_De-Blur"] = True
|
||||
if "Auto_De-Blur" not in win.settings:
|
||||
win.settings["Auto_De-Blur"] = True
|
||||
|
||||
# Fail switch for Graphics.
|
||||
if win.FPS < 10 and win.settings["Auto_De-Blur"]:
|
||||
win.settings["Blur"] = False
|
||||
# Fail switch for Graphics.
|
||||
if win.FPS < 10 and win.settings["Auto_De-Blur"]:
|
||||
win.settings["Blur"] = False
|
||||
|
||||
win.sFPS = datetime.datetime.now()
|
||||
win.sFPS = datetime.datetime.now()
|
||||
|
||||
win.cursors = {
|
||||
"arrow":Gdk.Cursor.new(Gdk.CursorType.ARROW),
|
||||
"watch":Gdk.Cursor.new(Gdk.CursorType.WATCH),
|
||||
"text" :Gdk.Cursor.new(Gdk.CursorType.XTERM),
|
||||
"hand" :Gdk.Cursor.new(Gdk.CursorType.HAND1),
|
||||
"cross":Gdk.Cursor.new(Gdk.CursorType.CROSS)
|
||||
}
|
||||
win.current["cursor"] = win.cursors["arrow"]
|
||||
win.cursors = {
|
||||
"arrow":Gdk.Cursor.new(Gdk.CursorType.ARROW),
|
||||
"watch":Gdk.Cursor.new(Gdk.CursorType.WATCH),
|
||||
"text" :Gdk.Cursor.new(Gdk.CursorType.XTERM),
|
||||
"hand" :Gdk.Cursor.new(Gdk.CursorType.HAND1),
|
||||
"cross":Gdk.Cursor.new(Gdk.CursorType.CROSS)
|
||||
}
|
||||
win.current["cursor"] = win.cursors["arrow"]
|
||||
|
||||
|
||||
# Getting update info. I've added a bit of delay. So the starting of the
|
||||
# Popen would not be noticed by the user as much.
|
||||
#if win.current["frame"] > 50:
|
||||
GLib.timeout_add(1 , update_reader.get_update_info, win)
|
||||
#t2 = threading.Thread(target=update_reader.get_update_info, args=(win,))
|
||||
#t2.start()
|
||||
# Getting update info. I've added a bit of delay. So the starting of the
|
||||
# Popen would not be noticed by the user as much.
|
||||
#if win.current["frame"] > 50:
|
||||
GLib.timeout_add(1 , update_reader.get_update_info, win)
|
||||
#t2 = threading.Thread(target=update_reader.get_update_info, args=(win,))
|
||||
#t2.start()
|
||||
|
||||
# Current frame (for animations and things like this)
|
||||
win.current["frame"] += 1
|
||||
# Current frame (for animations and things like this)
|
||||
win.current["frame"] += 1
|
||||
|
||||
# Getting data about the frame
|
||||
win.current['mx'] = win.get_pointer()[0]
|
||||
win.current['my'] = win.get_pointer()[1]
|
||||
win.current['w'] = win.get_size()[0]
|
||||
win.current['h'] = win.get_size()[1]
|
||||
# Getting data about the frame
|
||||
win.current['mx'] = win.get_pointer()[0]
|
||||
win.current['my'] = win.get_pointer()[1]
|
||||
win.current['w'] = win.get_size()[0]
|
||||
win.current['h'] = win.get_size()[1]
|
||||
|
||||
|
||||
#Background color
|
||||
UI_color.set(main_layer, win, "background")
|
||||
main_layer.rectangle(
|
||||
0,
|
||||
0,
|
||||
win.current['w'],
|
||||
win.current['h'])
|
||||
main_layer.fill()
|
||||
#Background color
|
||||
UI_color.set(main_layer, win, "background")
|
||||
main_layer.rectangle(
|
||||
0,
|
||||
0,
|
||||
win.current['w'],
|
||||
win.current['h'])
|
||||
main_layer.fill()
|
||||
|
||||
# Tooltips and other junk has to be defined here. And then drawn later to
|
||||
# the screen. So here we get a special layer. That will be drawn to during
|
||||
# the time of drawing. And later composeted over everything.
|
||||
# Tooltips and other junk has to be defined here. And then drawn later to
|
||||
# the screen. So here we get a special layer. That will be drawn to during
|
||||
# the time of drawing. And later composeted over everything.
|
||||
|
||||
win.tooltip_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
|
||||
win.current['h'])
|
||||
win.tooltip = cairo.Context(win.tooltip_surface)
|
||||
win.tooltip.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
win.tooltip_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
|
||||
win.current['h'])
|
||||
win.tooltip = cairo.Context(win.tooltip_surface)
|
||||
win.tooltip.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
|
||||
|
||||
# Layers. Order of them matter
|
||||
Layers = []
|
||||
Layers.append([pm_mainLayer.layer(win),"project_manager"])
|
||||
# Layers. Order of them matter
|
||||
Layers = []
|
||||
Layers.append([pm_mainLayer.layer(win),"project_manager"])
|
||||
|
||||
|
||||
# Call layers. See studio/studio_dialogs.py for explanation. It's wild.
|
||||
# Call layers. See studio/studio_dialogs.py for explanation. It's wild.
|
||||
|
||||
win.calllayer = False
|
||||
remlater = []
|
||||
win.calllayer = False
|
||||
remlater = []
|
||||
|
||||
for call in list(win.current["calls"].keys()):
|
||||
for call in list(win.current["calls"].keys()):
|
||||
|
||||
if win.current["calls"][call]["var"] == None:
|
||||
Layers.append([win.current["calls"][call]["draw"](win, call)])
|
||||
win.url = win.current["calls"][call]["url"]
|
||||
win.calllayer = True
|
||||
if win.current["calls"][call]["var"] == None:
|
||||
Layers.append([win.current["calls"][call]["draw"](win, call)])
|
||||
win.url = win.current["calls"][call]["url"]
|
||||
win.calllayer = True
|
||||
|
||||
else:
|
||||
win.url = win.current["calls"][call]["back"]
|
||||
win.current["calls"][call]["call"](win, win.current["calls"][call]["var"])
|
||||
win.textactive = ""
|
||||
remlater.append(call)
|
||||
|
||||
for call in remlater:
|
||||
|
||||
del win.current["calls"][call]
|
||||
|
||||
|
||||
|
||||
if win.url == "new_project":
|
||||
Layers.append([pm_newprojectLayer.layer(win), "new_project"])
|
||||
elif win.url == "scan_projects":
|
||||
Layers.append([pm_scanLayer.layer(win), "scan_projects"])
|
||||
elif win.url == "help_layer":
|
||||
Layers.append([pm_helpLayer.layer(win), "help_layer"])
|
||||
elif win.url == "update_layer":
|
||||
Layers.append([pm_updateLayer.layer(win), "update_layer"])
|
||||
elif win.url == "install_updates":
|
||||
Layers.append([pm_installUpdatesLayer.layer(win), "install_updates"])
|
||||
elif win.url == "settings_layer":
|
||||
Layers.append([pm_settingsLayer.layer(win), "settings_layer"])
|
||||
|
||||
|
||||
Layers.append([UI_testing.layer(win)])
|
||||
Layers.append([win.tooltip_surface])
|
||||
|
||||
# Combining layers
|
||||
for layer in Layers:
|
||||
if len(layer) > 1:
|
||||
layer, url = layer
|
||||
blur = UI_elements.animate(url+"_blur", win, 50)
|
||||
if win.url != url:
|
||||
blur = UI_elements.animate(url+"_blur", win, blur, 50, 2, True)
|
||||
else:
|
||||
blur = UI_elements.animate(url+"_blur", win, blur, 0, 2, True)
|
||||
layer = UI_elements.blur(layer, win, blur)
|
||||
else:
|
||||
layer = layer[0]
|
||||
main_layer.set_source_surface(layer, 0 , 0)
|
||||
main_layer.paint()
|
||||
win.url = win.current["calls"][call]["back"]
|
||||
win.current["calls"][call]["call"](win, win.current["calls"][call]["var"])
|
||||
win.textactive = ""
|
||||
remlater.append(call)
|
||||
|
||||
win.get_root_window().set_cursor(win.current["cursor"])
|
||||
for call in remlater:
|
||||
|
||||
# If you press ESC you get back from any window to the main menu.
|
||||
if 65307 in win.current["keys"] and win.url != "install_updates":
|
||||
win.url = "project_manager"
|
||||
win.current["project"] = ""
|
||||
win.textactive = ""
|
||||
del win.current["calls"][call]
|
||||
|
||||
|
||||
# Saving data about this frame for the next one. A bit hard to get WTF am I
|
||||
# doing here. Basically trying to avoid current and previous data to be links
|
||||
# of the same data.
|
||||
|
||||
previous(win) # Moved it into a seprate function for obvoius reasons
|
||||
if win.url == "new_project":
|
||||
Layers.append([pm_newprojectLayer.layer(win), "new_project"])
|
||||
elif win.url == "scan_projects":
|
||||
Layers.append([pm_scanLayer.layer(win), "scan_projects"])
|
||||
elif win.url == "help_layer":
|
||||
Layers.append([pm_helpLayer.layer(win), "help_layer"])
|
||||
elif win.url == "update_layer":
|
||||
Layers.append([pm_updateLayer.layer(win), "update_layer"])
|
||||
elif win.url == "install_updates":
|
||||
Layers.append([pm_installUpdatesLayer.layer(win), "install_updates"])
|
||||
elif win.url == "settings_layer":
|
||||
Layers.append([pm_settingsLayer.layer(win), "settings_layer"])
|
||||
|
||||
# Refreshing those that need to be refrashed
|
||||
win.current["scroll"] = [0,0]
|
||||
|
||||
# Refreshing the frame automatically
|
||||
pmdrawing.queue_draw()
|
||||
Layers.append([UI_testing.layer(win)])
|
||||
Layers.append([win.tooltip_surface])
|
||||
|
||||
# Combining layers
|
||||
for layer in Layers:
|
||||
if len(layer) > 1:
|
||||
layer, url = layer
|
||||
blur = UI_elements.animate(url+"_blur", win, 50)
|
||||
if win.url != url:
|
||||
blur = UI_elements.animate(url+"_blur", win, blur, 50, 2, True)
|
||||
else:
|
||||
blur = UI_elements.animate(url+"_blur", win, blur, 0, 2, True)
|
||||
layer = UI_elements.blur(layer, win, blur)
|
||||
else:
|
||||
layer = layer[0]
|
||||
main_layer.set_source_surface(layer, 0 , 0)
|
||||
main_layer.paint()
|
||||
|
||||
win.get_root_window().set_cursor(win.current["cursor"])
|
||||
|
||||
# If you press ESC you get back from any window to the main menu.
|
||||
if 65307 in win.current["keys"] and win.url != "install_updates":
|
||||
win.url = "project_manager"
|
||||
win.current["project"] = ""
|
||||
win.textactive = ""
|
||||
|
||||
|
||||
# Saving data about this frame for the next one. A bit hard to get WTF am I
|
||||
# doing here. Basically trying to avoid current and previous data to be links
|
||||
# of the same data.
|
||||
|
||||
previous(win) # Moved it into a seprate function for obvoius reasons
|
||||
|
||||
# Refreshing those that need to be refrashed
|
||||
win.current["scroll"] = [0,0]
|
||||
|
||||
# Refreshing the frame automatically
|
||||
pmdrawing.queue_draw()
|
||||
except:
|
||||
Gtk.main_quit()
|
||||
error_notify.show()
|
||||
|
||||
|
||||
|
||||
# This program will have things like mouse and keyboard input. And this setup
|
||||
|
@ -336,6 +345,7 @@ def key_press(widget, event, win):
|
|||
win.current["keys"].append(event.keyval)
|
||||
win.current["key_letter"] = event.string
|
||||
|
||||
|
||||
def key_release(widget, event, win):
|
||||
try:
|
||||
win.current["keys"].remove(event.keyval)
|
||||
|
|
|
@ -143,7 +143,7 @@ def layer(win):
|
|||
def after(win, var):
|
||||
pass
|
||||
|
||||
studio_dialogs.help(win, "help", after, SEARCH=talk.text("readme"))
|
||||
studio_dialogs.help(win, "help", after, SEARCH=talk.text("documentation_project_manager"))
|
||||
|
||||
UI_elements.roundrect(layer, win,
|
||||
5,
|
||||
|
|
Loading…
Reference in a new issue