You are viewing outdated content for BUG. If you have a BUG Y.T. edition or 2.0 series device, please visit our updated wiki: http://wiki.buglabs.net



PygtkDualScreen

From BUG Wiki

Jump to: navigation, search

Contents

Introduction

Here's an example code for using the 2 screens in one application(so you don't need 2 or more applications talking to each other).It uses pygtk and python

Code

Poky

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk

class GUI(object):
    def __init__(self):
        display1 = gtk.gdk.Display(':1.0')
        display0 = gtk.gdk.Display(':0.0')
        screen0 = display0.get_screen(0)
        screen1 = display1.get_screen(0)
        window0 = gtk.Window()
        window0.set_screen(screen0)
        window1 = gtk.Window()    
        window1.set_screen(screen1)
        label0 = gtk.Label("Display :0.0")
        label1 = gtk.Label("Display :1.0")
        window0.add(label0)
        window1.add(label1)
        window1.fullscreen()
        window0.show_all()
        window1.show_all()
        self.widget = [display0,display1] #this is a workarround for a bug...
if __name__ == "__main__" : 
    gui = GUI()
    gtk.main()

Angstrom

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk

class GUI(object):
    def __init__(self):
        display = gtk.gdk.display_get_default()
        screen0 = display.get_screen(0)
        screen1 = display.get_screen(1)
        window0 = gtk.Window()
        window0.set_screen(screen0)
        window1 = gtk.Window()    
        window1.set_screen(screen1)
        label0 = gtk.Label("Display :0.0")
        label1 = gtk.Label("Display :1.0")
        window0.add(label0)
        window1.add(label1)
        window1.fullscreen()
        window0.show_all()
        window1.show_all() 
if __name__ == "__main__" : 
    gui = GUI()
    gtk.main()

Run the code

To run the code copy that code into a file named pytgk_ds_test.py
then copy it to the bug device
then do:

export DISPLAY=:0.0

in order to make GTK find a display(else it won't work)
then do:

python pytgk_ds_test.py