# Use a function from a class to open a 2nd window

**URL:** <https://discourse.processing.org/t/use-a-function-from-a-class-to-open-a-2nd-window/19166>\
**Category:** Processing.py\
**Created:** [March 30, 2020, 2:06am UTC](https://discourse.processing.org/t/use-a-function-from-a-class-to-open-a-2nd-window/19166 "2020-03-30T02:06:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 30, 2020, 8:19am UTC](https://discourse.processing.org/t/use-a-function-from-a-class-to-open-a-2nd-window/19166/2 "2020-03-30T08:19:26Z")

</div>

Opening another window in Processing is akin to have a separate class w/ a new set of callbacks such as **settings()**, **setup()**, **draw()**, etc:

> [@Two windows with 'one draw()'](https://discourse.processing.org/t/two-windows-with-one-draw/11388/3):
>
> [Forum.Processing.org/two/discussion/16965/how-to-open-a-second-window#Item\_1](http://Forum.Processing.org/two/discussion/16965/how-to-open-a-second-window#Item_1)

> [@Improving the 'title' of a second window in Python Mode](https://discourse.processing.org/t/improving-the-title-of-a-second-window-in-python-mode/13746):
>
> Thanks to GoToLoop and others who discussed it here and on the earlier forums, I know I can make a sketch with more than one window like this: def setup(): size(200, 300) second\_window = OtherWindow() def draw(): background(0) ellipse(mouseX, mouseY, 10, 10) class OtherWindow(PApplet): def \_\_init\_\_(self): switches = ('--sketch-path=' + sketchPath(), '') PApplet.runSketch(switches, self) def settings(self): self.size(…

> [@How to use controlP5 in second window using python mode](https://discourse.processing.org/t/how-to-use-controlp5-in-second-window-using-python-mode/13253/6):
>
> After creating a more simplified example: sweat_smile # https://Discourse.Processing.org/t/ # how-to-using-controlp5-in-second-window-using-python-mode/13253/6 # GoToLoop (2019-Aug-19) add\_library('controlP5') def settings(): size(150, 150) Other() def setup(): ControlP5(this).addBang('Main').onClick(bangCallback) def draw(): background(0) def bangCallback(v): print v.controller class Other(PApplet): SW\_PATH = '--sketch-path=' MAGENTA = 0xFFff00ff d…

> [@SeanW](#):
>
> I plan on then plotting ellipses or rectangles based on variables in an instance of DHTable.

If your class DHTable directly issues “drawing” commands such as **ellipse()**, **fill()**, etc., not only it has to know which PApplet’s canvas those commands will act upon, it’s gotta make sure they’re executed under the same Thread as that PApplet’s reference!

---

_[View the full topic](https://discourse.processing.org/t/use-a-function-from-a-class-to-open-a-2nd-window/19166)._
