Text input in python

Discussion about user contributed plugins

Moderator: Moderator

Fredde
veteran
Posts: 288
Joined: Tue Dec 06, 2005 7:18 am
Location: Sweden

Text input in python

Postby Fredde » Thu Feb 21, 2008 3:28 pm

I have created a new control that will enable text input in the python plugin. The control is called TextFieldControl. I also added that feature to the TextBoxControl. These two controls can be used in two "modes", static text or as input fields. There is a method called setEnabled that changes that behaviour.

Get it from:

Link removed because the input doesn't work with lirc.

The download contains a diff which is compatible with mms-1.1.0-1420+
Apply the diff in the mms-1.1.0 tree root NOT in the python folder.

Code: Select all

patch -p0 < python-plugin.diff


The download also contains two simple demo scripts.
Last edited by Fredde on Tue Feb 26, 2008 9:54 pm, edited 1 time in total.

User avatar
acmelabs
Overlord
Posts: 2365
Joined: Mon Feb 20, 2006 9:18 pm
Location: Germany
Contact:

Re: Text input in python

Postby acmelabs » Thu Feb 21, 2008 4:19 pm

Fredde wrote:I have created a new control that will enable text input in the python plugin. The control is called TextFieldControl. I also added that feature to the TextBoxControl. These two controls can be used in two "modes", static text or as input fields. There is a method called setEnabled that changes that behaviour.

Get it from:

http://hem.bredband.net/mmsv2/python-textinput.tgz

The download contains a diff which is compatible with mms-1.1.0-1420+
Apply the diff in the mms-1.1.0 tree root NOT in the python folder.

Code: Select all

patch -p0 < python-plugin.diff


The download also contains two simple demo scripts.

Wow!
Thanks a lot.
Will test asap.

Regards,
Andreas

Fredde
veteran
Posts: 288
Joined: Tue Dec 06, 2005 7:18 am
Location: Sweden

Postby Fredde » Sat Feb 23, 2008 7:54 am

It came to my mind that i only tested the input with keyboard. I fired up lirc and it obviously didn't work :oops: I will continue to work on that and also fix some other issues (like crash in empty script dir).

Fredde
veteran
Posts: 288
Joined: Tue Dec 06, 2005 7:18 am
Location: Sweden

Postby Fredde » Sun Mar 02, 2008 8:46 pm

I have just completed the TextFieldControl for the python plugin (rev 1468) which makes it possible to get text input from the user.

The control is similar to the LabelControl. It can be used in two "modes", static text or input field. There is a method called setEditable that changes that behaviour.

Here is a example using the TextFieldControl:

Code: Select all

import mmsv2gui

class TextFieldWindow(mmsv2gui.Window):
  def __init__(self):

    self.bg = mmsv2gui.ImageControl(0, 0, self.getWidth(), self.getHeight(), "general/bg.png")
    self.input = mmsv2gui.TextFieldControl(50, 250, 500, 40, "Press the action key to enable input")

    self.addControl(self.bg)
    self.addControl(self.input)

    self.setFocus(self.input)

  def onAction(self, action):

    print self.input.getText()

    if action == "back":
      self.close()

    if action == "action":
      if self.getFocus() == self.input:
        self.input.setEditable(True)

win = TextFieldWindow()
win.doModal()

del win


In rev 1468 I also implemented the exit action for the python plugin. This makes it possible to "jump" form a script to the mms start menu, without terminating the script. The running script will be "resumed" when entering the python plugin later on.

User avatar
acmelabs
Overlord
Posts: 2365
Joined: Mon Feb 20, 2006 9:18 pm
Location: Germany
Contact:

Postby acmelabs » Mon Mar 03, 2008 6:57 am

Fredde wrote:...[/code]

In rev 1468 I also implemented the exit action for the python plugin. This makes it possible to "jump" form a script to the mms start menu, without terminating the script. The running script will be "resumed" when entering the python plugin later on.

Pretty pretty cool stuff. Thanks a lot!

Regards,
Andreas

Fredde
veteran
Posts: 288
Joined: Tue Dec 06, 2005 7:18 am
Location: Sweden

Postby Fredde » Mon Mar 03, 2008 7:32 am

acmelabs wrote:
Fredde wrote:...[/code]

In rev 1468 I also implemented the exit action for the python plugin. This makes it possible to "jump" form a script to the mms start menu, without terminating the script. The running script will be "resumed" when entering the python plugin later on.

Pretty pretty cool stuff. Thanks a lot!

Regards,
Andreas


Another feature that is possible to implement is running two or more scripts simultaneously, and then shift between the running scripts (and of course the script lauching menu). Any need for such a feature?

User avatar
acmelabs
Overlord
Posts: 2365
Joined: Mon Feb 20, 2006 9:18 pm
Location: Germany
Contact:

Postby acmelabs » Mon Mar 03, 2008 9:43 am

Fredde wrote:Another feature that is possible to implement is running two or more scripts simultaneously, and then shift between the running scripts (and of course the script lauching menu). Any need for such a feature?

Wow, wait a moment, I'm not at home, and want to try it at least one time.
This feature request would also be nice: http://forum.mymediasystem.org/viewtopi ... =7447#7447
But I also know, it's not very realistic to expect a implementation at the current state of development. But we should be this in mind, since the python-plugin becomes more and more a central place for plugin development.

Thanks a lot!

Regards,
Andreas


Return to “user plugins”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest