def main(): GLib.threads_init() Clutter.init(sys.argv) MainWindow() Clutter.main()
def __init__(self, argv, descriptor): super().__init__() Clutter.init(sys.argv) # application main window, instance of :see: :class: `window.Window`: self.window = None # path to a file with style definition: self.style = None # dictionary for all the application basic elements: self.box = {} # if playing of the sound effects should be enabled: self.sound_effects_enabled = False # indicator of the application main loop status, should be used # with caution as there will always be some non-zero time interval # between setting this flag 'True' and actual launching of the loop and # between actual quit of the loop and setting the flag 'False': self.main_loop_is_running = False # player of any audio effects: self.sound_effects_player = None self._sound_effects = {} self._read_descriptor(descriptor) self._configure() self._initialize_style() self._initialize_window(argv, descriptor) self._initialize_sound_effects_player()
def __init__(self): Clutter.init([]) self.__latitude = None self.__longitude = None self.__selected_marker = None self.__active_sensitive = False self.__marker_last_location = None self.__factory = Champlain.MapSourceFactory.dup_default() self.__set_location_context_menu = None self.__locations = [] self.__task_locations = {} self.__tag_locations = {} self.__view = None self.__vbox_map = None self.__map = None self.__current_layer = None self.__menu_item_tag_sidebar = None self.__plugin_api = None self.__where = Geoclue() self.__where.client.connect_to_signal( 'LocationUpdated', self._location_updated ) self.__where.client.Start() self.__distance = 15 self.__preferences = None
def start(self): """Starts the Clutter main event loop and sets our kernel startup routine. """ # Register our function to initiate the kernel and start Clutter GObject.idle_add(self._wire_kernel) Clutter.init([]) Clutter.main()
def __init__(self, container, argv): PisakEduApp.APP = self Clutter.init(argv) self.stage = PisakEduStage(container) self.stage.connect("destroy", lambda _: Clutter.main_quit()) self.stage.set_fullscreen(True) self.stage.show_all()
def main(): hello_str = chr_chr = '' x_offset = y_offset = idx = 0 # initialize Clutter Clutter.init(sys.argv) if (len(sys.argv) > 1): hello_str = argv[0] else: hello_str = 'Hello Clutter!' # create a Stage stage = Clutter.Stage() # set the title of the Stage window stage.set_title('Hello, Clutter') # set the background color of the Stage stage_color = Clutter.Color() Clutter.Color.from_string(stage_color, 'DarkSlateGray') stage.set_color(stage_color) # connect the pointer button press and key press event signals stage.connect('button-press-event', on_button_press) stage.connect('key-press-event', on_key_press) stage.connect('destroy', Clutter.main_quit) # set the size of the Stage stage.set_size(800, 600) # then show the Stage stage.show_all()
def finish_initializing(self, builder): # pylint: disable=E1002 """Set up the camera dialog""" super(CameraMugshotDialog, self).finish_initializing(builder) # Initialize Gst or nothing will work. Gst.init(None) Clutter.init(None) self.camera = CameraBox(self) self.camera.show() self.camera.connect("gst-state-changed", self.on_camera_state_changed) self.camera.connect("photo-saved", self.on_camera_photo_saved) # Pack the video widget into the dialog. vbox = builder.get_object('camera_box') vbox.pack_start(self.camera, True, True, 0) # Essential widgets self.record_button = builder.get_object('camera_record') self.apply_button = builder.get_object('camera_apply') # Store the temporary filename to be used. self.filename = None self.show_all()
def __init__(self, argv): PisakSpellerApp.APP = self Clutter.init(argv) self.stage = PisakSpellerStage() TimerCycle(self.stage.contents).start_cycle() self.stage.connect("destroy", lambda _: Clutter.main_quit()) self.stage.set_fullscreen(True) self.stage.show_all()
def __init__(self): Clutter.init() self.stage = TextStage() self.stage.connect("destroy", lambda *_: Clutter.main_quit()) self.stage.show_all() Clutter.main()
def __init__(self): GObject.GObject.__init__(self, type=Gtk.WindowType.POPUP) Clutter.init(None) # animation self._stage = Clutter.Stage.get_default() self._move_animation = None self._opacity_animation = None
def default_stage(): import gi gi.require_version('Clutter', '1.0') from gi.repository import Clutter, GLib Clutter.init([]) stage = Clutter.Stage() stage.set_size(800, 500) stage.set_title('Clutter - Cairo content') stage.set_user_resizable(True) return stage
def run(self): # Import clutter only in the gobject thread # This function will be the running mainloop try: from gi.repository import Clutter as clutter clutter.threads_init() clutter.init([]) clutter.main() except Exception, e: log.exception('unable to import clutter') return
def __init__(self): Clutter.init(None) ui = Clutter.Script() ui.load_from_file("ui-threads.json") stage = ui.get_object("stage") stage.connect("destroy", self.stop) stage.connect("destroy", lambda w: Clutter.main_quit()) self.loader = ui.get_object("loader") self.loader.set_from_file("style/loading.png") self.t = Clutter.PropertyTransition(property_name='rotation-angle-z') self.t.set_from(0) self.t.set_to(360) self.t.set_duration(3000) self.t.set_animatable(self.loader) self.t.set_repeat_count(-1) self.t.start() button1 = ui.get_object("button1") button1.connect("button-press-event", self.execute_in_main) button1.set_reactive(True) button2 = ui.get_object("button2") button2.connect("button-press-event", self.idle_add_event) button2.set_reactive(True) button3 = ui.get_object("button3") button3.connect("button-press-event", self.threads_idle_add_event) button3.set_reactive(True) button4 = ui.get_object("button4") button4.connect("button-press-event", self.execute_in_thread) button4.set_reactive(True) stage = ui.get_object("stage") stage.set_title("Test threads") stage.connect("destroy", self.stop) stage.show_all() self.events = JoinableQueue(10) # UI events needs to happen from within the # main thread. This was the only way I found that would do that. # It looks weirdm, but it works. def execute(event): print("Execute " + event + " from " + str(current_thread())) for i in range(100): hashlib.md5(str(list(range(100000)))) print("Done executing") self.execute = execute stage.show()
def create_ui(self): Clutter.init() Clutter.threads_init() self.clutter = GtkClutter.Embed() self.clutter.set_size_request(420, 280) self.stage = self.clutter.get_stage() self.stage.set_background_color(Clutter.Color .from_string('#8c8c8c')[1]) self.stage.show_all() self.widget.add(self.clutter)
def __init__(self): # initialize Clutter Clutter.init([]) self.colors = { 'white': Clutter.Color.new(0, 0, 0, 255), 'blue': Clutter.Color.new(16, 16, 32, 255), 'black': Clutter.Color.new(255, 255, 255, 128), 'hand': Clutter.Color.new(16, 32, 16, 196) } # create a resizable stage stage = Clutter.Stage.new() stage.set_title("2D Clock") stage.set_user_resizable(True) stage.set_background_color(self.colors['blue']) stage.set_size(300, 300) stage.show() # our 2D canvas, courtesy of Cairo canvas = Clutter.Canvas.new() canvas.set_size(300, 300) actor = Clutter.Actor.new() actor.set_content(canvas) actor.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR, Clutter.ScalingFilter.LINEAR) stage.add_child(actor) # bind the size of the actor to that of the stage actor.add_constraint( Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.SIZE, 0)) # resize the canvas whenever the actor changes size actor.connect("allocation-changed", self.on_actor_resize) # quit on destroy stage.connect("destroy", self.on_destroy) # connect our drawing code canvas.connect("draw", self.draw_clock) # invalidate the canvas, so that we can draw before the main loop starts Clutter.Content.invalidate(canvas) # set up a timer that invalidates the canvas every second Clutter.threads_add_timeout(GLib.PRIORITY_DEFAULT, 1000, self.invalidate_clock, canvas) Clutter.main()
def __init__(self, argv): """ Initialize the application. Call methods that initialize application stage, style and global sound effects player. :param: argv application arguments """ super().__init__() Gtk.init(sys.argv) Clutter.init(sys.argv) self._configure() self._initialize_style() self._initialize_window(argv) self._initialize_sound_effects_player()
def __init__ (self): # initialize Clutter Clutter.init([]) self.colors = { 'white' : Clutter.Color.new(0, 0, 0, 255), 'blue' : Clutter.Color.new(16, 16, 32, 255), 'black' : Clutter.Color.new(255, 255, 255, 128), 'hand' : Clutter.Color.new(16, 32, 16, 196) } # create a resizable stage stage = Clutter.Stage.new () stage.set_title ("2D Clock") stage.set_user_resizable (True) stage.set_background_color (self.colors['blue']) stage.set_size (300, 300) stage.show () # our 2D canvas, courtesy of Cairo canvas = Clutter.Canvas.new () canvas.set_size (300, 300) actor = Clutter.Actor.new () actor.set_content (canvas) actor.set_content_scaling_filters (Clutter.ScalingFilter.TRILINEAR, Clutter.ScalingFilter.LINEAR) stage.add_child (actor) # bind the size of the actor to that of the stage actor.add_constraint(Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.SIZE, 0)) # resize the canvas whenever the actor changes size actor.connect ("allocation-changed", self.on_actor_resize) # quit on destroy stage.connect ("destroy", self.on_destroy) # connect our drawing code canvas.connect ("draw", self.draw_clock) # invalidate the canvas, so that we can draw before the main loop starts Clutter.Content.invalidate (canvas) # set up a timer that invalidates the canvas every second Clutter.threads_add_timeout (GLib.PRIORITY_DEFAULT, 1000, self.invalidate_clock, canvas) Clutter.main ()
def main(): if len(sys.argv) < 2: print "Usage: %s [OPTIONS] <video file> [logo file]" % (sys.argv[0]) else: if DEBUG: Clutter.init(debugArgs) else: Clutter.init(sys.argv) filename = sys.argv[1] if len(sys.argv) > 2: logo = sys.argv[2] else: logo = None app = VideoApp(filename, logo) Clutter.main()
def test_style_loader(default_config): config = default_config config.file_base = abspath(join(dirname(__file__), "../..")) styles = ["Plain", "Mixer", "Spitzy"] resolutions = ["1920x1080", "1280x720", "800x480"] Clutter.init(None) for style in styles: for res in resolutions: config['Screen']['width'] = res.split("x")[0] config['Screen']['height'] = res.split("x")[1] config['Screen']['rotation'] = "0" config['Style']['style'] = style loader = StyleLoader(config) assert (loader.load_ui(loader.ui_file_path))
def main(): Clutter.init(sys.argv) # Tests guy = PPGuy.PPGuy() guy.set_property("direction", 100) guy.connect("collide", collide_cb) print guy.get_property("direction") maze = PPMaze.PPMaze() print maze.get_property("width") print maze.get_property("height") guy.emit("collide", PPGuy.PPGuy()) game = PPGame.PPGame() Mx.Application.run(game)
def setup_stage(config): stage_color = Clutter.Color.new(0, 0, 0, 0) text_color = Clutter.Color.new(0, 128, 0, 255) Clutter.init(sys.argv) stage = Clutter.Stage() stage.set_title("Speakup") stage.set_use_alpha(True) stage.set_background_color(stage_color) stage.connect("delete-event", stage_on_delete, config) stage.connect("button-press-event", stage_on_button_press, config) layout = Clutter.BoxLayout() layout.set_orientation(Clutter.Orientation.VERTICAL) layout.set_spacing(15) stage.set_layout_manager(layout) old_entries = [] for i in range(15): old_entry = Clutter.Text.new_with_text("Sans 28px", "") old_entry.set_color(Clutter.Color.new(0, 128, 0, (i + 1) * 16)) old_entries.append(old_entry) stage.add_actor(old_entry) old_entries.reverse() entry = Clutter.Text.new_with_text("Sans 28px", "") entry.set_color(text_color) entry.set_editable(True) entry.set_reactive(True) entry.set_single_line_mode(True) entry.set_line_alignment(Pango.Alignment.CENTER) entry.connect("key-press-event", entry_on_key_press, config) stage.add_actor(entry) entry.old_entries = old_entries entry.old_iterator = -1 stage.show() stage.set_fullscreen(True) stage.set_key_focus(entry) stage_window = ClutterGdk.get_stage_window(stage) stage_window.set_keep_above(True) stage_window.set_modal_hint(True) stage_window.set_skip_taskbar_hint(True) stage_window.set_skip_pager_hint(True)
def enable(self, app=None): """Enable event loop integration with Clutter. Parameters ---------- app : ignored Ignored, it's only a placeholder to keep the call signature of all gui activation methods consistent, which simplifies the logic of supporting magics. Notes ----- This methods sets the PyOS_InputHook for Clutter, which allows the Clutter to integrate with terminal based applications like IPython. """ if GUI_CLUTTER not in self.manager.apps: Clutter.init([]) self.manager.set_inputhook(inputhook_clutter) self.manager._current_gui = GUI_CLUTTER self.manager.apps[GUI_CLUTTER] = True
# taken from https://github.com/cubicool/clutter-pygobject-examples import sys sys.path.insert(0, '../..') import pgi pgi.install_as_gi() import math from gi.repository import Clutter initialized, sys.argv = Clutter.init(sys.argv) FRAGMENT_SHADER_VARS = """ uniform sampler2D tex; uniform float x_step, y_step; """ FRAGMENT_SHADER_BEGIN = """ void main() { vec4 color = texture2D(tex, vec2(cogl_tex_coord_in[0])); """ FRAGMENT_SHADER_END = """ gl_FragColor = color; gl_FragColor = gl_FragColor * cogl_color_in; } """ FRAGMENTS = FRAGMENT_SHADER_VARS, FRAGMENT_SHADER_BEGIN, FRAGMENT_SHADER_END
def _initialize_stage(self, argv): # create and set up a Clutter.Stage Clutter.init(argv) self._initialize_style() self.stage = self.create_stage(argv) self.stage.connect("destroy", lambda _: Clutter.main_quit())
def __init__(self): self.version = "1.2.1" logging.info("Starting Toggle " + self.version) file_path = os.path.join("/etc/toggle", "local.cfg") if not os.path.exists(file_path): logging.info(file_path + " does not exist, Creating one") os.mknod(file_path) os.chmod(file_path, 0o777) # Parse the config files. config = CascadingConfigParser([ '/etc/toggle/default.cfg', '/etc/toggle/printer.cfg', '/etc/toggle/local.cfg' ]) # Get loglevel from the Config file level = config.getint('System', 'loglevel') if level > 0: logging.getLogger().setLevel(level) sys.stdout = LoggerWriter(config, logging, 20) sys.stderr = LoggerWriter(config, logging, 50) Clutter.init(None) style = Mx.Style.get_default() style.load_from_file(config.get("System", "stylesheet")) config.ui = Clutter.Script() try: config.ui.load_from_file(config.get("System", "ui")) except: print "Error loading UI" import traceback traceback.print_exc() config.stage = config.ui.get_object("stage") config.stage.connect("destroy", self.stop) config.stage.connect('key-press-event', self.key_press) # Set up tabs config.tabs = CubeTabs(config.ui, 4) config.splash = Splash(config) config.splash.set_status("Starting Toggle " + self.version + "...") config.jog = Jog(config) config.temp_graph = TemperatureGraph(config) config.filament_graph = FilamentGraph(config) # Set up SockJS and REST clients host = config.get("Rest", "hostname") config.rest_client = RestClient(config) # Add other stuff config.volume_stage = VolumeStage(config) config.message = Message(config) config.printer = Printer(config) config.loader = ModelLoader(config) config.plate = Plate(config) config.socks_client = WebSocksClient(config, host="ws://" + host + ":5000") # mouse use_mouse = int(config.get('System', 'mouse')) self.cursor = config.ui.get_object("cursor") if use_mouse: config.stage.connect("motion-event", self.mouse_move) logging.info("Mouse is active") else: logging.info("Mouse is not active") self.cursor.set_opacity(0) config.push_updates = JoinableQueue(10) self.config = config config.plate.make_scale() config.stage.show()
# for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk from gi.repository import Gdk from gi.repository import Clutter from antler_settings import AntlerSettings from math import sqrt import os import sys import gobject Clutter.init("antler") class AnimatedWindowBase(Gtk.Window, Clutter.Animatable): __gproperties__ = { 'antler-window-position': (gobject.TYPE_PYOBJECT, 'Window position', 'Window position in X, Y coordinates', gobject.PARAM_READWRITE) } def __init__(self): gobject.GObject.__init__(self, type=Gtk.WindowType.POPUP) # animation self._stage = Clutter.Stage.get_default() self._move_animation = None self._opacity_animation = None
import sys import unittest import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GObject, Gdk, Gio from tests import skipIfGI try: from gi.repository import Clutter Clutter except ImportError: Clutter = None else: status, argv = Clutter.init(sys.argv) if status == Clutter.InitError.SUCCESS: sys.argv = argv else: Clutter = None class ObjectTest(unittest.TestCase): def test_classes(self): g = GObject.Object() self.assertTrue(isinstance(g, GObject.Object)) a = Gtk.AccelMap() self.assertTrue(isinstance(a, type(g))) def test_init_1(self):
def on_key_press_event(self, stage, event): print('on_key_press_event', event) if event.unicode_value: c = event.unicode_value if c in 'qx': self.on_destroy(stage, event) print('quit') elif c in 'pP': self.player.set_state(Gst.State.PAUSED) print('pause') elif c in 'gG': self.player.set_state(Gst.State.PLAYING) print('play') elif c in 'sS': self.player.seek_simple( Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0) self.player.set_state(Gst.State.PAUSED) print('stop') if __name__ == '__main__': from sys import argv GObject.threads_init() Gst.init(argv) ClutterGst.init(argv) Clutter.init(argv) video = Video(*argv[1:]) Clutter.main()
self.connect("key-release-event", self.key_release) self.connect("notify::mapped", self.start_focus) self.button = MyButton() self.add_child(self.button) self.set_layout_manager(Clutter.BoxLayout()) def start_focus(self, source, *args): # set focus to the box self.get_stage().set_key_focus(source) def key_release(self, source, *args): print("KEY RELEASE: BOX") # set focus to the button source.get_stage().set_key_focus(self.button) class MyStage(Clutter.Stage): def __init__(self): super().__init__() self.box = MyBox() self.add_child(self.box) self.set_layout_manager(Clutter.BinLayout()) if __name__ == '__main__': Clutter.init([]) stage = MyStage() stage.show() stage.connect("destroy", lambda _: Clutter.main_quit()) Clutter.main()
from gi.repository import Clutter if __name__ == '__main__': Clutter.init(None) # The main stage stage = Clutter.Stage(title='Constraints', user_resizable=True) stage.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.ALUMINIUM_1) stage.connect('destroy', Clutter.main_quit) # First actor, with a fixed (100, 25) size layer_a = Clutter.Actor() layer_a.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.SCARLET_RED) layer_a.set_size(100, 25) stage.add_child(layer_a) # The first actor is anchored to the center of the stage layer_a.add_constraint(Clutter.AlignConstraint(source=stage, align_axis=Clutter.AlignAxis.BOTH, factor=0.5)) # Second actor, with no explicit size layer_b = Clutter.Actor() layer_b.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.BUTTER_DARK) stage.add_child(layer_b) # The second actor tracks the X coordinate and the width of the first actor layer_b.add_constraint(Clutter.BindConstraint(source=layer_a, coordinate=Clutter.BindCoordinate.X)) layer_b.add_constraint(Clutter.BindConstraint(source=layer_a, coordinate=Clutter.BindCoordinate.WIDTH)) # The second actor is snapped between the bottom edge of the first actor # and the bottom edge of the stage; vertical spacing of 10px is added for # padding
args = sys.argv[1:] parser = ArgumentParser(description='Demonstrate drawing SVG on Clutter ' 'stage') parser.add_argument('svg_path') parser.add_argument('shape', nargs='?', default=None) args = parser.parse_args(args) return args if __name__ == "__main__": args = parse_args() print args Clutter.init() Clutter.Settings().props.double_click_time = 100 stage = Clutter.Stage() if args.shape is not None: width, height = map(int, args.shape.split('x')) stage.set_size(width, height) stage.set_title("SVG paths as actors") stage.set_user_resizable(True) stage.connect("destroy", lambda x: Clutter.main_quit()) group = SvgGroup(args.svg_path) stage.add_actor(group) stage.show_all() group.add_constraint(Clutter.BindConstraint
def __init__(self, argv): Clutter.init(argv) self._build_stage() self._load_script() self._load_stylesheet() self._init_dispatcher()
def __init__(self, argv): PisakEduApp.APP = self Clutter.init(argv) self._init_context() self._init_stage()
# version 2.1 of the License, or (at your option) any later version. import sys import unittest import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk, Gdk, Atk, Gio, GLib try: from gi.repository import Clutter Clutter except ImportError: Clutter = None else: status, argv = Clutter.init(sys.argv) if status == Clutter.InitError.SUCCESS: sys.argv = argv else: Clutter = None from tests import FIXME, skipUnlessCairo, skipIfGI class StructTest(unittest.TestCase): @skipUnlessCairo def test_foreign_cairo(self): window = Gtk.OffscreenWindow() area = Gtk.DrawingArea() window.add(area)
#!/usr/bin/python3 #! -*- coding: utf-8 -*- import gi gi.require_version('Clutter', '1.0') from gi.repository import Clutter import sys def keyPress(self, event, _actor): _actor.set_position(200, 100) _actor.animatev(Clutter.AnimationMode.EASE_OUT_BOUNCE, 1500, ["x"], [20]) if __name__ == '__main__': Clutter.init(sys.argv) # Create Stage _stage = Clutter.Stage() _stage.set_title("Basic Usage") _stage.set_size(400, 200) # Create Actor _red = Clutter.Color().new(255, 0, 0, 255) # R,G,B,alpha _actor = Clutter.Text().new_full("Mono 10", "Hello World!", _red) _actor.set_position(100, 100) _actor_anim = _actor.animatev(Clutter.AnimationMode.EASE_OUT_BOUNCE, 1500, ["x"], [20]) # Add Actor to the Stage
#!/usr/bin/env python3 # Test Clutter # HanishKVC, v20201124IST1127 # import enum # Import Clutter for use import gi gi.require_version('Clutter', '1.0') from gi.repository import Clutter import cluttergui as cg # Initialise Clutter.init() # required things colorizeEffect1 = Clutter.ColorizeEffect() colorizeEffect1.set_tint(Clutter.color_from_pixel(0xE0E0F0FF)) print(colorizeEffect1.get_tint().to_string()) # Handle events def handle_btn_press(actor, event): print("INFO:BtnPress:{},{}".format(actor, event)) print("\t x,y [{},{}], btn [{}]".format(event.x, event.y, event.button)) if actor == stage: print("INFO: Bowing down gracefully") Clutter.main_quit() elif actor in (imgBtn1, imgBtn2): print("INFO: Button is pressed:", actor.get_id())
def __init__(self): from .__init__ import __version__ logging.info("Initializing Toggle {}".format(__version__)) config_files = ['default.cfg', 'printer.cfg', 'local.cfg'] config_paths = [os.path.join(Toggle.CONFIG_BASE, f) for f in config_files] config = CascadingConfigParser(config_paths) # Get loglevel from the Config file level = config.getint('System', 'loglevel') if level > 0: logging.getLogger().setLevel(level) sys.stdout = LoggerWriter(config, logging, logging.INFO) sys.stderr = LoggerWriter(config, logging, logging.FATAL) Clutter.init(None) config.file_base = Toggle.CONFIG_BASE config.style = StyleLoader(config) config.style.load_from_config() config.ui = config.style.ui config.stage = config.ui.get_object("stage") config.stage.connect("destroy", self.stop) config.stage.connect('key-press-event', self.key_press) config.style.do_screen_rotation() config.tabs = CubeTabs(config.ui, 4) config.splash = SplashPage(config) config.splash.set_status("Starting Toggle {} ...".format(__version__)) config.jog = JogPage(config) config.temp_graph = TemperaturePage(config) config.network = Network.get_manager(config) config.settings = SettingsPage(config) config.rest_client = RestClient(config) config.volume_stage = VolumeStage(config) config.message = MessageBox(config) config.printer = PrintPage(config) config.loader = ModelLoader(config) config.model = Model(config) config.plate = Plate(config) config.socks_client = WebSocksClient(config, self.on_connected_cb) # mouse use_mouse = int(config.get('Input', 'mouse')) self.cursor = config.ui.get_object("cursor") if use_mouse: config.stage.connect("motion-event", self.mouse_move) logging.info("Mouse is active") else: config.stage.connect("touch-event", self.mouse_move) logging.info("Mouse is not active, using touch instead") self.cursor.set_opacity(0) config.mouse_invert_x = config.getboolean('Input', 'mouse_invert_x') config.mouse_invert_y = config.getboolean('Input', 'mouse_invert_y') config.mouse_swap = config.getboolean('Input', 'mouse_swap_xy') config.push_updates = Queue.Queue(10) self.config = config config.stage.show()
# for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject from gi.repository import Clutter from antler_settings import AntlerSettings from math import sqrt import os import sys Clutter.init("antler") class AnimatedWindowBase(Gtk.Window, Clutter.Animatable): __gproperties__ = { 'antler-window-x' : (GObject.TYPE_INT, 'Window position', 'Window X coordinate', GObject.G_MININT, GObject.G_MAXINT, 0, GObject.PARAM_READWRITE), 'antler-window-y' : (GObject.TYPE_INT, 'Window position', 'Window Y coordinate', GObject.G_MININT, GObject.G_MAXINT, 0, GObject.PARAM_READWRITE) } def __init__(self): GObject.GObject.__init__(self, type=Gtk.WindowType.POPUP)
def setUp(self): Clutter.init([])
def main(): Clutter.init([]) stage = ButtonStage() stage.connect("destroy", lambda _: Clutter.main_quit()) stage.show_all() Clutter.main()
import subprocess import logging from gi.repository import Clutter, Mx, Mash, Toggle, Cogl, GObject # Set up logging logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M') if __name__ == '__main__': Clutter.init(None) stage = Clutter.Stage() stage.set_size(800, 500) stage.set_title('Clutter - Cairo content') stage.set_user_resizable(True) stage.connect("destroy", lambda w: Clutter.main_quit()) model = Toggle.Model() model.load_from_file(0, "/home/root/.octoprint/uploads/reel2.stl") model.set_color(Clutter.Color.from_string("#55A94BFF")[1]) model.set_position(400, 200) stage.add_child(model) stage.show_all() Clutter.main()
label.set_x_align(Clutter.ActorAlign.START) label.set_x_expand(True) box.add_child(label) label.connect('clicked', label_clicked_cb, scroll) # Handle Unix signal to terminate this application by your terminal. def handle_unix_signal(): Clutter.main_quit() GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, handle_unix_signal) if Clutter.init(sys.argv)[0] != Clutter.InitError.SUCCESS: print('fail') sys.exit() stage = Clutter.Stage.new() stage.set_title('Pan Action') stage.set_user_resizable(True) scroll = create_scroll_actor(stage) stage.add_child(scroll) box = Clutter.Actor.new() stage.add_child(box) box.set_position(12, 12) layout = Clutter.BoxLayout.new()
#!/usr/bin/python from gi.repository import Gdk from gi.repository import ClutterGst from gi.repository import Clutter from gi.repository import GtkClutter from gi.repository import Gst from gi.repository import Gtk Gdk.init([]) Gtk.init([]) GtkClutter.init([]) Gst.init([]) Clutter.init([]) ClutterGst.init([]) window = Gtk.Window() texture = Clutter.Texture.new() sink = Gst.ElementFactory.make("cluttersink", None) sink.props.texture = texture src = Gst.ElementFactory.make("videotestsrc", None) pipeline = Gst.Pipeline() pipeline.add(src, sink) src.link(sink) embed = GtkClutter.Embed() embed.set_size_request(320, 240) stage = embed.get_stage() stage.add_child(texture)
""" Toggles fullscreen. """ if self._is_fullscreen: self._stage.set_fullscreen(False) self._is_fullscreen = False else: self._stage.set_fullscreen(True) self._is_fullscreen = True if __name__ == "__main__": DEBUG = False if DEBUG: DEBUG_ARGS = ['--clutter-debug=all', '--cogl-debug=all'] Clutter.init(DEBUG_ARGS) else: Clutter.init(sys.argv) config = Configuration() config.filenames = ["a.mov", "b.mov", "c.mov"] if len(config.filenames) == 0: print("You must choose at least one video file name.") app = Application(config) try: Clutter.main() except KeyboardInterrupt, e: pass sys.exit(0)
item2 = body_ref(element.tag) item2.setFromAttrib(element.attrib) items.append(item2) item.setItems(items) region_ids = {} region_names = {} xml = ET.parse(sys.argv[1]) root = xml.find('./head/layout/root-layout') smil_rootlayout = layout_rootlayout() smil_rootlayout.setFromAttrib(root.attrib) Clutter.init(sys.argv) ClutterGst.init(sys.argv) stage = Clutter.Stage.get_default() stage.set_title("SMIL") smil_rootlayout.clutter(stage) for region in xml.findall('./head/layout/region'): smil_region = layout_region() smil_region.setFromAttrib(region.attrib) if '{http://www.w3.org/XML/1998/namespace}id' in region.attrib: region_ids[region.attrib['{http://www.w3.org/XML/1998/namespace}id']] = smil_region if 'regionName' in region.attrib:
def main(): Clutter.init(sys.argv) Test() Clutter.main()