Kivy: Interactive Applications in Python by 未知
Author:未知
Language: eng
Format: epub
Publisher: Packt Publishing
The structure in line94 to 100 is already familiar. Line 96 makes sure that the ToolButton is in the 'down' state and that the event happened in the DrawingSpace instance (referenced by ds). Remember that the parent of the ToolButton is ToolBox, and that we added an attribute that references the DrawingSpace instance in comiccreator.kv at the beginning of the chapter.
The draw method is called in line 98 and it will draw the respective shapes according to the derived classes (ToolStickMan, ToolCircle, and ToolLine). We need to be sure that we send the right coordinates to the draw method. Therefore, before calling on it we need to translate the absolute coordinates of the event to relative coordinates with the to_widget event (line 97). We know that the coordinates we received (touch.x and touch.y) are absolute because ToolStickman is not a RelativeLayout, whereas the DrawingSpace (ds) is.
Let's continue studying the toolbox.py file and see how ToolStickMan actually adds the StickMan instances:
104. class ToolStickman(ToolButton): 105. def draw(self, ds, x, y): 106. sm = StickMan(width=48, height=48) 107. sm.center = (x,y) 108. ds.add_widget(sm)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26518)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19001)
The Fifty Shades Trilogy & Grey by E L James(18953)
Shot Through the Heart by Mercy Celeste(18877)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(16976)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16869)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16796)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16690)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16316)
The Subtle Art of Not Giving a F*ck by Mark Manson(14251)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14067)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13414)
Scorched Earth by Nick Kyme(12708)
Drei Generationen auf dem Jakobsweg by Stein Pia(10919)
Suna by Ziefle Pia(10843)
Scythe by Neal Shusterman(10265)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9473)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9313)
This is Going to Hurt by Adam Kay(9090)
