Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
Free text:
{{ Translation | lang = ko | source = GTK Graphics Sample Activity | version = 50507 }} {{Korean}} GTK (특히, PyGTK)를 이용하여 슈가 액티비티 속에서 그래픽을 처리하는 방법을 보여주는 한 액티비티입니다. 이 액티비티는 GTK 그리기 명령어를 이용하여 블랙 스퀘어 속에 그린 스퀘어를 그립니다. 아무 키나 누르면, 중단됩니다. # # Minimal GTK Graphics Activity # # This demo shows how to set things up to do GTK graphics # in the Sugar environment. # import pygtk pygtk.require('2.0') import gtk import sys from sugar.activity import activity class MinimalGtkGraphicsActivity(activity.Activity): """Minimal GTK Graphics activity. Sets up the window for drawing and draws a rectangle inside another rectangle when the window is shown to the user. Waits for a key press and then quits. """ def __init__(self, handle): activity.Activity.__init__(self, handle) # remove any children of the window that Sugar may have added for widget in self.get_children(): self.remove(widget) self.set_title("Drawing Area Example") # Set up event handlers self.connect("destroy", lambda w: gtk.main_quit()) self.connect("expose-event", self.area_expose_cb) self.connect("key_press_event", self.keypress_cb) self.show() # Set up the drawing area and graphics context self.area = self.window self.gc = self.area.new_gc() # Set up the colors to draw with self.colormap = self.gc.get_colormap() self.colors = {} self.colors['green'] = self.colormap.alloc_color('green') self.colors['black'] = self.colormap.alloc_color('black') def keypress_cb(self, widget, event): """Handle a key press""" sys.exit() def area_expose_cb(self, area, event): """Window exposed callback, includes drawing the boxes""" self.gc.set_foreground(self.colors['black']) self.area.draw_rectangle(self.gc, True, 100, 100, 300, 300) self.gc.foreground = self.colors['green'] self.area.draw_rectangle(self.gc, True, 200, 200, 100, 100) return True [[Category:Tutorials]] [[Category:Activities]]
General Activity Info (for latest tested version)
To add another activity version that works with other builds click "add another"
Version number:
Releases tested on: 7.1.0 (650) 7.1.1 (653) 7.1.2 (656) 8.1.0 (703) 8.1.1 (708) 8.2.0 (767) 8.2.1 Candidate
Development status: 1. Planning 2. Pre-Alpha 3. Alpha 4. Beta 5. Production-stable 6. Mature
Summary::
This is a minor edit Watch this page
Cancel