Added standard cursors; added alerts.
This commit is contained in:
parent
27fbb7ecb6
commit
5ebf5ff4ab
|
|
@ -91,6 +91,8 @@ def onKeyDownGroup(self, key):
|
|||
pass
|
||||
if key in [" ", "s", "r", "e", "b"]:
|
||||
svlgui.MODE=key
|
||||
svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair",
|
||||
"b":"arrow"}[key], MainWindow.stage)
|
||||
elif key=="F6":
|
||||
add_keyframe()
|
||||
print "Added keyframe."
|
||||
|
|
@ -99,6 +101,8 @@ def onKeyDownObj(self, key):
|
|||
del self.parent[self.parent.index(self)] # Need to clean up deletion
|
||||
elif key in [" ", "s", "r", "e", "b"]:
|
||||
svlgui.MODE=key
|
||||
svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair",
|
||||
"b":"arrow"}[key], MainWindow.stage)
|
||||
elif key=="F6":
|
||||
add_keyframe()
|
||||
|
||||
|
|
@ -198,11 +202,12 @@ def quit(widget):
|
|||
|
||||
|
||||
def add_keyframe(widget=None):
|
||||
svlgui.alert("test alert", True)
|
||||
root.descendItem().add_frame(True)
|
||||
print root.descendItem().activeframe*16
|
||||
b = svlgui.Image("media/keyframe_active.png",root.descendItem().activeframe*16,0,True,MainWindow.timelinebox,16,1)
|
||||
frames.add(b)
|
||||
frames.draw()
|
||||
MainWindow.timelinebox.draw()
|
||||
def add_layer(widget=None):
|
||||
root.descendItem().add_layer(root.descendItem()._al)
|
||||
layers.add(svlgui.Image("media/object_active.png",0,root.descendItem().layers.index(root.descendItem().activelayer)*32,True,MainWindow.layerbox,16,1))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
import svlgui
|
||||
import misc_funcs
|
||||
from misc_funcs import *
|
||||
|
||||
class MainWindow:
|
||||
|
|
@ -183,6 +184,7 @@ class MainWindowOSX:
|
|||
self.window = svlgui.Window("Lightningbeam")
|
||||
self.menu = svlgui.Menu(True, None)
|
||||
self.stage = svlgui.Canvas(800,600)
|
||||
misc_funcs.stage = self.stage
|
||||
self.layerbox = svlgui.Canvas(128,320)
|
||||
self.timelinebox = svlgui.Canvas(2000,320)
|
||||
self.frame = svlgui.Frame()
|
||||
|
|
|
|||
|
|
@ -3,24 +3,34 @@ from threading import Event, Thread
|
|||
|
||||
def select_any(self):
|
||||
svlgui.MODE = " "
|
||||
svlgui.set_cursor("arrow", stage)
|
||||
def resize_any(self):
|
||||
svlgui.MODE = " "
|
||||
svlgui.MODE = "s"
|
||||
svlgui.set_cursor("arrow", stage)
|
||||
def lasso(self):
|
||||
svlgui.MODE = "l"
|
||||
svlgui.set_cursor("lasso", stage)
|
||||
def text(self):
|
||||
svlgui.MODE = "t"
|
||||
svlgui.set_cursor("text", stage)
|
||||
def rectangle(self):
|
||||
svlgui.MODE = "r"
|
||||
svlgui.set_cursor("crosshair", stage)
|
||||
def ellipse(self):
|
||||
svlgui.MODE = "e"
|
||||
svlgui.set_cursor("crosshair", stage)
|
||||
def curve(self):
|
||||
svlgui.MODE = "c"
|
||||
svlgui.set_cursor("curve", stage)
|
||||
def paintbrush(self):
|
||||
svlgui.MODE = "p"
|
||||
svlgui.set_cursor("paintbrush", stage)
|
||||
def pen(self):
|
||||
svlgui.MODE = "n"
|
||||
svlgui.set_cursor("pen", stage)
|
||||
def paint_bucket(self):
|
||||
svlgui.MODE = "b"
|
||||
svlgui.set_cursor("bucket", stage)
|
||||
|
||||
def box(x, y, width, height, fill):
|
||||
global objects
|
||||
|
|
|
|||
37
svlgui.py
37
svlgui.py
|
|
@ -120,7 +120,7 @@ if sys.platform=="linux2":
|
|||
import GUI # Using PyGUI. Experimental.
|
||||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, StdCursors, Alerts
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
from GUI.Geometry import offset_rect, rect_sized
|
||||
|
|
@ -130,14 +130,14 @@ if sys.platform=="linux2":
|
|||
SYSTEM="html"
|
||||
ids = {}
|
||||
jsdefs = []
|
||||
jsfunctions = ""
|
||||
sep = "/"'''
|
||||
jsfunctions = ""'''
|
||||
sep = "/"
|
||||
elif sys.platform=="win32":
|
||||
import pickle
|
||||
import GUI # Using PyGUI. Experimental.
|
||||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, StdCursors, Alerts
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
from GUI.Geometry import offset_rect, rect_sized
|
||||
|
|
@ -156,7 +156,7 @@ elif sys.platform=="darwin":
|
|||
import GUI # Using PyGUI. Experimental.
|
||||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, StdCursors, Alerts
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
from GUI.Geometry import offset_rect, rect_sized
|
||||
|
|
@ -614,10 +614,13 @@ class Canvas(Widget):
|
|||
63235:"right_arrow",63234:"left_arrow",13:"enter",9:"tab",
|
||||
63236:"F1",63237:"F2",63238:"F3",63239:"F4",63240:"F5",
|
||||
63241:"F6",63242:"F7",63243:"F8",}
|
||||
if not event.unichars=='':
|
||||
if ord(event.unichars) in keydict:
|
||||
key = keydict[ord(event.unichars)]
|
||||
else:
|
||||
key = event.unichars
|
||||
else:
|
||||
key = event.key.upper()
|
||||
for i in self.objs:
|
||||
i._onKeyDown(key)
|
||||
self.invalidate_rect([0,0,self.extent[0],self.extent[1]])
|
||||
|
|
@ -1489,11 +1492,23 @@ class Group (object):
|
|||
retval+=j.frames[i].print_sc()
|
||||
return retval
|
||||
|
||||
def set_cursor(curs, widget=None):
|
||||
if SYSTEM == "osx":
|
||||
cursdict = {"arrow":StdCursors.arrow, "ibeam":StdCursors.ibeam,
|
||||
"crosshair":StdCursors.crosshair, "fist":StdCursors.fist,
|
||||
"hand":StdCursors.hand, "finger":StdCursors.finger, "invisible":StdCursors.invisible}
|
||||
if curs in cursdict:
|
||||
if widget:
|
||||
widget._int().cursor = cursdict[curs]
|
||||
else:
|
||||
app.cursor = cursdict[curs]
|
||||
else:
|
||||
print "Sorry, I don't have that cursor."
|
||||
|
||||
def alert(text,critical=False):
|
||||
'''Launches an alert window with a given text.
|
||||
If critical is True, closing the alert terminates SWIFT.'''
|
||||
if SYSTEM=="gtk":
|
||||
#Launches an alert window with a given text.
|
||||
#If critical is True, closing the alert terminates SWIFT.
|
||||
def abutton_press_event(widget, event):
|
||||
#Close when "Ok" is pressed
|
||||
alert.destroy()
|
||||
|
|
@ -1529,6 +1544,13 @@ def alert(text,critical=False):
|
|||
ahbox.show() # make it visible
|
||||
avbox.show() # make the vbox visible
|
||||
alert.show() # make the alert itself visible
|
||||
elif SYSTEM=="osx":
|
||||
#Much simpler. :)
|
||||
if critical:
|
||||
Alerts.stop_alert(text) # stop_alert is a critical error alert
|
||||
sys.exit(0) # Exit to OS. Sometimes we can't recover an error.
|
||||
else:
|
||||
Alerts.note_alert(text) # note_alert is a general alert, i.e. "I'm a computer."
|
||||
elif SYSTEM=="html":
|
||||
jscommunicate("alert("+text+")")
|
||||
if critical:
|
||||
|
|
@ -1581,6 +1603,7 @@ class OverlayWindow:
|
|||
gobject.timeout_add(50, expose, win, 'fade-event', time.time())
|
||||
gobject.timeout_add(2000, win.destroy)
|
||||
|
||||
|
||||
class ColorSelectionWindow:
|
||||
def __init__(self,var,dispgrp, dcanv):
|
||||
if SYSTEM=="gtk":
|
||||
|
|
|
|||
Loading…
Reference in New Issue