×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    14

    Question Hello, screen On/Off, How ?

    Hi all.

    I'm working on a small, stupid app'.
    I need to make the screen totally white with back light for 20sec'
    How can i do that with Py?, not sure how to draw white nothing.

    Thank you very much.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: Hello, screen On/Off, How ?

    Take a look:

    Code:
    import appuifw, e32
    
    def redraw(rect):
        # all white
        canvas.clear(0xffffff)
    
    # This won't work:
    #appuifw.app.body = canvas = appuifw.Canvas(redraw_callback=redraw)
    # This will:
    canvas = appuifw.app.body = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.screen = 'full'
    e32.reset_inactivity()
    This creates a full-screen canvas control that is filled with white color. The reset_inactivity call will light the backlight up. For more information, refer to the PyS60 documentation.

    -- EDIT --
    The code above has been updated after it was pointed in the later posts that it was broken.
    Last edited by y.a.k; 2007-10-27 at 06:19. Reason: Code fixed.

  3. #3
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: Hello, screen On/Off, How ?

    Quote Originally Posted by y.a.k View Post
    Take a look:

    Code:
    import appuifw, e32
    
    def redraw(rect):
        # all white
        canvas.clear(0xffffff)
    
    appuifw.app.body = canvas = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.screen = 'full'
    e32.reset_inactivity()
    This creates a full-screen canvas control that is filled with white color. The reset_inactivity call will light the backlight up. For more information, refer to the PyS60 documentation.

    Hello

    Dear y.a.k

    I think your code is faulty and specially the line
    Code:
    appuifw.app.body = canvas = appuifw.Canvas(redraw_callback=redraw)
    Also you need to import the graphics module too.
    You cant assign of canvas to appuifw.app.body until you have assigned the value to canvas. No matter you have assinged the value appuifw.Canvas(redraw_callback=redraw) to canvas later in the statement but it wont work.There should be 2 separate statements like
    Code:
    canvas = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.body = canvas
    The above will work fine.Moreover your code is right (except the statement i pointed above) though it will need a delay in between that can ofcourse be easily introduced to meet the requirement of Sick Spider
    Quote Originally Posted by Sick Spider View Post
    Hi all.

    I'm working on a small, stupid app'.
    I need to make the screen totally white with back light for 20sec'
    How can i do that with Py?, not sure how to draw white nothing.

    Thank you very much.
    So Hi Sick Spider below is a code to your requirement
    Code:
    import appuifw, e32
    import graphics
    
    def redraw(rect):
        # all white screen
        canvas.clear(0xffffff)
    
    canvas = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.body = canvas 
    appuifw.app.screen = 'full'
    e32.ao_sleep(20) # Wait for 20 Seconds 
    e32.reset_inactivity()
    Hope it Helps
    Last edited by croozeus; 2007-10-24 at 13:10. Reason: mistype :)
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: Hello, screen On/Off, How ?

    @croozeus

    Hi, sorry but I think you're wrong here. Test done a minute ago in the console:
    Code:
    >>> a=b=2
    >>> a
    2
    >>> b
    2
    >>>
    This is really legal in Python, I use it quite often.

    And you don't need the graphics module. If you don't access it in your code, you don't have to import it. You will need it as soon as you start creating some more sophisticated graphics on the canvas, like drawing images (graphics.Image), but for a white screen, there's no need to import graphics.

    And did he really mean backlight *after* 20 seconds or lighted up *for* 20 seconds. If the latter, all he can do is to turn it on immediately (by calling e32.reset_inactivity()). As you know, there's no way to turn it back off after 20 seconds.

  5. #5
    Registered User
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    14

    Re: Hello, screen On/Off, How ?

    ThnX alot guys !!!.
    I'll give it a try tonight.

    Thank You !!.
    What The..%^$#

  6. #6
    Registered User
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    14

    Re: Hello, screen On/Off, How ?

    Hi Guys.

    Here is what i wrote, i mirror and flashlight script... yeah yeah.. i know.. sounds weird...

    However, the black (mirror, black canvas) part doesn't work, any ideas why ?.

    Code:
    import appuifw, e32
    import graphics
    
    def flashWhite(rect):
        canvas.clear(0xffffff)
    def mirrorBlack(rect):
        canvas.clear(0x000000)
    
    appuifw.note(u"Welcome to MirrFlash", "info")
    lookOption = [u"Flashlight?", u"Mirror?"]
    noteToSelect = appuifw.popup_menu(lookOption, u"Both will be active for 20 Sec'")
    
    if noteToSelect == 0:
        #flashlight here
        canvasWhite = appuifw.Canvas(redraw_callback=flashWhite)
        appuifw.app.body = canvasWhite 
        appuifw.app.screen = 'full'    
        e32.ao_sleep(20)
        e32.reset_inactivity()
      
    if noteToSelect == 1:
        #mirror here
        canvasBlack = appuifw.Canvas(redraw_callback=mirrorBlack)
        appuifw.app.body = canvasBlack 
        appuifw.app.screen = 'full'    
        e32.ao_sleep(20)
        e32.reset_inactivity()
        
    appuifw.note(u"Done.", "info")
    Thank You very much.
    Last edited by Sick Spider; 2007-10-25 at 23:37.
    What The..%^$#

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: Hello, screen On/Off, How ?

    The 'canvas' object you reference in both flashWhite() and mirrorBlack() functions doesn't exist. You probably want to put 'canvasWhite' and 'canvasBlack' (respectively) there. The flashlight "worked" because Canvas objects are white by default.

  8. #8
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: Hello, screen On/Off, How ?

    Quote Originally Posted by y.a.k View Post
    @croozeus

    Hi, sorry but I think you're wrong here. Test done a minute ago in the console:
    Code:
    >>> a=b=2
    >>> a
    2
    >>> b
    2
    >>>
    This is really legal in Python, I use it quite often.

    And you don't need the graphics module. If you don't access it in your code, you don't have to import it. You will need it as soon as you start creating some more sophisticated graphics on the canvas, like drawing images (graphics.Image), but for a white screen, there's no need to import graphics.

    And did he really mean backlight *after* 20 seconds or lighted up *for* 20 seconds. If the latter, all he can do is to turn it on immediately (by calling e32.reset_inactivity()). As you know, there's no way to turn it back off after 20 seconds.
    Hello y.a.k

    I tested your previous code and also with the numericals regarding the assignment operator.The a=b=2 works fine but your previous code doesnt work.So i guess the above a=b=2 system of assignment works for only datatypes (int,strings,etc) but not with functions. Also your previous code had the error that canvas is not defined.So i had edited your code to below and it worked..
    Code:
    import appuifw, e32
    import graphics
    
    def redraw(rect):
        # all white screen
        canvas.clear(0xffffff)
    
    canvas = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.body = canvas 
    appuifw.app.screen = 'full'
    e32.ao_sleep(20) # Wait for 20 Seconds 
    e32.reset_inactivity()
    I want you to test your previous code on the device and check whether you get the same errors or not?
    Pankaj Nathani
    www.croozeus.com

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    386

    Re: Hello, screen On/Off, How ?

    Ok, I have tested the code now. Previously I just typed it into the browser without checking.

    You're right - it doesn't work. But not because you can't use functions in a=b=x constructs.

    I made a test and it seems that in case of such a construct:
    Code:
    a = b = c = x
    first, the value 'x' is evaluated and assigned to a, then assigned to 'b' and then to 'c'.

    So in my code:
    Code:
    def redraw(rect):
        canvas.clear(0xffffff)
    
    appuifw.app.body = canvas = appuifw.Canvas(redraw_callback=redraw)
    First, the Canvas object is created, then it is assigned to appuifw.app.body. During the assignment, the UI framework puts it on the screen. This in turn causes the redraw_callback to be called which in turn references the 'canvas' object which hasn't yet been assigned to. This causes an error.

    The solution is to divide the assignments into two separate ones, like you did, or change the assignment like this:
    Code:
    canvas = appuifw.app.body = appuifw.Canvas(redraw_callback=redraw)
    This works (checked). First, the Canvas is assigned to 'canvas' variable and then it is put on the screen so that when the redraw_callback is called, the 'canvas' already point to the object.

  10. #10
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: Hello, screen On/Off, How ?

    Hi y.a.k

    See I told you! Anyways I have also tested your new code...No probs with it! Cheers
    And Sick Spider What kinda application you are trying to build with this type of feature?
    Pankaj Nathani
    www.croozeus.com

  11. #11
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Re: Hello, screen On/Off, How ?

    Hi all..

    anyone can make a python script for turn off the screen light.
    i need it for battery saving..

    thx.

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    4

    Re: Hello, screen On/Off, How ?

    I tried the following code to have a flashlight on.
    Code:
    import appuifw, e32
    import graphics
    
    def redraw(rect):
        # all white screen
        canvas.clear(0xffffff)
    
    canvas = appuifw.Canvas(redraw_callback=redraw)
    appuifw.app.body = canvas 
    appuifw.app.screen = 'full'
    e32.ao_sleep(100) # Wait for 100 Seconds 
    e32.reset_inactivity()
    What function should I use to be able to switch off the flashlight using ANY key on the keyboard?
    While the sun hangs in the sky and the desert has sand
    While the waves crash in the sea and meet the land
    While there's a wind and the stars and the rainbow
    'Till the mountains crumble into the plain

Similar Threads

  1. Custom window in ALL screen modes
    By PawelDefee in forum Symbian
    Replies: 11
    Last Post: 2009-02-11, 09:19
  2. Problem with E90 and secondary screen
    By Tatanka.nbr1 in forum Symbian
    Replies: 5
    Last Post: 2008-06-27, 10:01
  3. Direct Screen Access (Please Comment!)
    By earamsey in forum Symbian
    Replies: 1
    Last Post: 2006-07-28, 18:34
  4. Full screen splash screen
    By jitendrachhajed in forum Symbian
    Replies: 1
    Last Post: 2005-07-11, 08:01
  5. UI: Full Screen Mode
    By GENERAL_INFO in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-11-22, 06:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •