コード例 #1
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def close(self):
        '''
		Deletes the window from the screen.

		@rtype: void
		'''
        _platform.Platform().close(self)
        _platform.Platform().deleteGWindow(self)
コード例 #2
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def setLabel(self, str):
		'''
		Changes the string stored within the GLabel object, so that
		a new text string appears on the display.

		@type str: string
		@rtype: void
		'''
		self.str = str
		_platform.Platform().setLabel(self, str)
		size = _platform.Platform().getGLabelSize(self)
		self.width = size.getWidth()
		self.height = size.getHeight()
コード例 #3
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def getText(self):
        '''
		Returns the contents of the text field.

		@rtype: string
		'''
        return _platform.Platform().getText(self)
コード例 #4
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def getValue(self):
        '''
		Returns the current value of the slider.

		@rtype: int
		'''
        return _platform.Platform().getValue(self)
コード例 #5
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def __init__(self, width, height, x = 0, y = 0, raised = False):
		'''
		Initializes a new 3D rectangle with the specified width and height.  If
		the x and y parameters are specified, they
		are used to specify the origin.  The raised parameter
		determines whether the rectangle should be drawn with highlights that
		suggest that it is raised about the background.

		@type width: float
		@type height: float
		@type x: float
		@type y: float
		@type raised: boolean
		@rtype: void
		'''
		GRect.__init__(self, width, height)
		self.x = x
		self.y = y
		self.width = width
		self.height = height
		self.raised = raised
		self.fillFlag = False
		self.fillColor = ""
		_platform.Platform().createG3DRect(self, width, height, str(raised).lower())
		self.setLocation(x=x, y=y)
コード例 #6
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def isSelected(self):
        '''
		Returns true if the check box is selected.

		@rtype: boolean
		'''
        return _platform.Platform().isSelected(self)
コード例 #7
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
def getScreenHeight():
    '''
	Returns the height of the entire display screen.

	@rtype: float
	'''
    return _platform.Platform().getScreenHeight()
コード例 #8
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def repaint(self):
        '''
		Schedule a repaint on this window.

		@rtype: void
		'''
        _platform.Platform().repaint(self)
コード例 #9
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def getSelectedItem(self):
        '''
		Returns the current item selected in the chooser.

		@rtype: string
		'''
        return _platform.Platform().getSelectedItem(self)
コード例 #10
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
def getScreenWidth():
    '''
	Returns the width of the entire display screen.

	@rtype: float
	'''
    return _platform.Platform().getScreenWidth()
コード例 #11
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def getBounds(self):
		'''
		Gets the bounding rectangle for this object

		@rtype: GRectangle
		'''
		if(self.transformed): return _platform.Platform().getBounds(self)
		rx = self.frameWidth / 2
		ry = self.frameHeight / 2
		cx = self.x + rx
		cy = self.y + ry
		startRadians = self.start * _gmath.PI / 180
		sweepRadians = self.sweep * _gmath.PI / 180
		p1x = cx + math.cos(startRadians) * rx
		p1y = cy - math.sin(startRadians) * ry
		p2x = cx + math.cos(startRadians + sweepRadians) * rx
		p2y = cy - math.sin(startRadians + sweepRadians) * ry
		xMin = min(p1x, p2x)
		xMax = max(p1x, p2x)
		yMin = min(p1y, p2y)
		yMax = max(p1y, p2y)
		if (self.containsAngle(0)): xMax = cx + rx
		if (self.containsAngle(90)): yMin = cy - ry
		if (self.containsAngle(180)): xMin = cx - rx
		if (self.containsAngle(270)): yMax = cy + ry
		if (self.isFilled()):
			xMin = min(xMin, cx)
			yMin = min(yMin, cy)
			xMax = max(xMax, cx)
			yMax = max(yMax, cy)
		return _gtypes.GRectangle(xMin, yMin, xMax - xMin, yMax - yMin)
コード例 #12
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def setFilled(self, flag):
		'''
		Sets the fill status for the arc, where false is
		outlined and true is filled.  If a GArc is
		unfilled, the figure consists only of the arc itself.  If a
		GArc is filled, the figure consists of the
		pie-shaped wedge formed by connecting the endpoints of the arc to
		the center.  As an example, the following program draws a 270-degree
		arc starting at 45 degrees, filled in yellow, much like the character
		in the PacMan video game::

			gw = _gwindow.GWindow()
			print("This program draws the PacMan character.")
			cx = gw.getWidth() / 2
			cy = gw.getHeight() / 2
			r = 25
			pacman = gobjects.GArc(cx - r, cy - r, 2*r, 2*r, 45, 270)
			pacman.setFilled(True)
			pacman.setFillColor("YELLOW")
			gw.add(pacman)

		@type flag: boolean
		@rtype: void
		'''
		self.fillFlag = flag
		_platform.Platform().setFilled(self, flag)
コード例 #13
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def __init__(self, width, height, start, sweep, x=0, y=0):
		'''
		Initializes a new GArc object consisting of an elliptical arc.
		The first form creates a GArc whose origin is the point
		(0, 0); the second form positions the GArc at the
		point (x, y).

		@type width: float
		@type height: float
		@type start: float
		@param start: degrees
		@type sweep: float
		@param sweep: degrees
		@type x: float
		@type y: float
		@rtype: void
		'''
		GObject.__init__(self)
		self.x = x
		self.y = y
		self.frameWidth = width
		self.frameHeight = height
		self.start = start
		self.sweep = sweep
		self.fillFlag = False
		self.fillColor = ""
		_platform.Platform().createGArc(self, width, height, start, sweep)
		self.setLocation(x=x, y=y)
コード例 #14
0
ファイル: gevents.py プロジェクト: SarahPythonista/acmpy
def waitForEvent(mask = EventClassType.ANY_EVENT):
    '''
    Dismisses the process until an event occurs whose type is covered by
    the event mask.  The mask parameter is a combination of the events of
    interest.  For example, to wait for a mouse event or an action event,
    clients can use the following call:

    e = waitForEvent(MOUSE_EVENT + ACTION_EVENT);

    The mask parameter is optional.  If it is missing,
    waitForEvent accepts any event.

    As a more sophisticated example, the following code is the canonical
    event loop for an animated application that needs to respond to mouse,
    key, and timer events::

        timer = gtimer.GTimer(ANIMATION_DELAY_IN_MILLISECONDS);
        timer.start()
        while(True):
            e = gevents.waitForEvent(TIMER_EVENT + MOUSE_EVENT + KEY_EVENT)
            if(e.getEventClass == gevents.EventClassType.TIMER_EVENT):
                takeAnimationStep()
            elif(e.getEventClass == gevents.EventClassType.MOUSE_EVENT):
                handleMouseEvent(e)
            elif(e.getEventClass == gevents.EventClassType.KEY_EVENT):
                handleKeyEvent(e)

    @type mask: EventClassType
    @param mask: EventClassType to wait for, defaults to ANY_EVENT
    @rtype: GEvent
    '''
    import spgl.private.platform as _platform
    return _platform.Platform().waitForEvent(mask)
コード例 #15
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def clear(self):
        '''
		Clears the contents of the window.

		@rtype: void
		'''
        self.gwd.top.removeAll()
        _platform.Platform().clear(self)
コード例 #16
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def setValue(self, value):
        '''
		Sets the current value of the slider.

		@type value: int
		@rtype: void
		'''
        _platform.Platform().setValue(self, value)
コード例 #17
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def getBounds(self):
		'''
		Returns the GRectangle bounding this object

		@rtype: GRectangle
		'''
		if(self.transformed): return _platform.Platform().getBounds(self)
		return _gtypes.GRectangle(self.x, self.y, self.width, self.height)
コード例 #18
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def setSelected(self, state):
        '''
		Sets the state of the check box.

		@type state: boolean
		@rtype: void
		'''
        _platform.Platform().setSelected(self, state)
コード例 #19
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def removeAt(self, index):
		'''
		Internal method
		'''
		gobj = self.contents[index]
		self.contents.pop(index)
		_platform.Platform().remove(gobj)
		gobj.parent = None
コード例 #20
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def setText(self, str):
        '''
		Sets the text of the field to the specified string.

		@type str: string
		@rtype: void
		'''
        _platform.Platform().setText(self, str)
コード例 #21
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def setVisible(self, flag):
        '''
		Determines whether the window is visible on the screen.

		@rtype: void
		'''
        self.gwd.visible = flag
        _platform.Platform().setVisible(flag, gw=self)
コード例 #22
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def __initGWindow(self, width, height, visible):
        self.gwd = GWindowData(width, height, visible)
        self.gwd.top = _gobjects.GCompound()

        _platform.Platform().createGWindow(self, width, height, self.gwd.top)

        self.setColor("BLACK")
        self.setVisible(visible)
コード例 #23
0
ファイル: ginteractors.py プロジェクト: SarahPythonista/acmpy
    def addItem(self, item):
        '''
		Adds a new item consisting of the specified string.

		@type item: string
		@rtype: void
		'''
        _platform.Platform().addItem(self, item)
コード例 #24
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
def exitGraphics():
    '''
    Closes all graphics windows and exits from the application without
    waiting for any additional user interaction.

    @rtype: void
    '''
    _platform.Platform().exitGraphics()
コード例 #25
0
ファイル: gtimer.py プロジェクト: SarahPythonista/acmpy
    def start(self):
        """Starts the timer.

        A timer continues to generate timer events until it
        is stopped; to achieve the effect of a one-shot timer, the simplest
        approach is to call the <code>stop</code> method inside the event
        handler.
        """
        _platform.Platform().gtimer_start(self)
コード例 #26
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def __init__(self):
		'''
		Creates a GCompound object with no internal components.

		@rtype: void
		'''
		GObject.__init__(self)
		self.contents = []
		_platform.Platform().createGCompound(self)
コード例 #27
0
ファイル: gobjects.py プロジェクト: SarahPythonista/acmpy
	def setRaised(self, raised):
		'''
		Indicates whether this object appears raised.

		@type raised: boolean
		@rtype: void
		'''
		self.raised = raised
		_platform.Platform().setRaised(self, str(raised).lower())
コード例 #28
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
def pause(milliseconds):
    '''
	Pauses for the indicated number of milliseconds.  This function is
	useful for animation where the motion would otherwise be too fast.

	@type milliseconds: int
	@rtype: void
	'''
    _platform.Platform().pause(milliseconds)
コード例 #29
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def setWindowTitle(self, title):
        '''
		Sets the title of the graphics window.

		@type title: string
		@rtype: void
		'''
        self.gwd.windowTitle = title
        _platform.Platform().setWindowTitle(self, title)
コード例 #30
0
ファイル: gwindow.py プロジェクト: SarahPythonista/acmpy
    def requestFocus(self):
        '''
		Asks the system to assign the keyboard focus to the window, which
		brings it to the top and ensures that key events are delivered to
		the window.  Clicking in the window automatically requests the focus.

		@rtype: void
		'''
        _platform.Platform().requestFocus(self)