Re: [viff-devel] GUI programming for Python/VIFF

2009-02-26 Thread Martin Geisler
Håvard Vegge  writes:

> I don't know what you mean with the issue "synchronization of program
> counters", but as far as my simple GUI application goes, it just
> works. At least for now...

Great! Tomas is currently lying at the beach in Barbados[1]..., but when
he get's back I hope he will share his experiences with GUI programs.

[1]: http://fc09.ifca.ai/

> Another question related to GUI; say we have n players which all have
> some secret input. Is it possible to make a progress bar of how many
> inputs that is currently submitted? Or is this information
> unavailable?

When you do

  a, b, c = runtime.shamir_share(range(1, n+1), Zp, my_input)

you can attach callbacks to the three shares. If self.pbar is a
gtk.ProgressBar something like this should do the trick:

  self.shares = 0

  def step(value):
  self.shares += 1
  self.pbar.set_fraction(self.shares / float(n))
  return value

  a.addCallback(step)
  b.addCallback(step)
  c.addCallback(step)

The idea is to make the callback update the progress bar, but otherwise
pass the value through unharmed.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.


pgpsjvv9AOgGF.pgp
Description: PGP signature
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


Re: [viff-devel] GUI programming for Python/VIFF

2009-02-26 Thread Håvard Vegge

Martin Geisler wrote:


I would go for PyGTK, which has a Twisted integration available:

http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html#auto11

This is important in order to be able to run both the network and
graphical event loops.

(...) 


I talked about this with Tomas Toft just the other day, so maybe he
can contribute more to the pseudo-code :-)

There were a slightly tricky issue with the synchronization of program
counters that we had to think about, but now I don't remember the
details. But I know that Tomas has a photo of our blackboard... :-)
  

Thanks, then PyGTK it is! ;-)

I don't know what you mean with the issue "synchronization of program 
counters", but as far as my simple GUI application goes, it just works. 
At least for now...


Another question related to GUI; say we have n players which all have 
some secret input. Is it possible to make a progress bar of how many 
inputs that is currently submitted? Or is this information unavailable?


Håvard
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


Re: [viff-devel] GUI programming for Python/VIFF

2009-02-10 Thread Martin Geisler
Håvard Vegge  writes:

Hi Håvard

> I'm developing a small application that will use VIFF. Instead of
> inputting values through the command line I would like to create a
> simple graphical interface.

That is an excellent idea!

> Have anyone experience with such GUI toolkits? Any recommendations?
>
> - I've barely tested PyQt, but it has some dual commercial/GPL
> license that I probably want to avoid.
> - Tkinter is the "standard" GUI toolkit for Python, but is reported
> to have a non-native look and feel.
> - wxPython is maybe the most popular GUI toolkit for Python, so
> perhaps I give it a try.

I would go for PyGTK, which has a Twisted integration available:

  
http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html#auto11

This is important in order to be able to run both the network and
graphical event loops.

I once played with it, please see

  viff/apps/double-auction/client.py

for a simple program that uses PyGTK with Twisted. It doesn't do
anything VIFF related, though.

In order to actually do something VIFFy with it, I imagine you would
have a button with a callback like this:

  def start_clicked():
r = create_runtime(...)
r.addCallback(go)

The go function could then let one of the players input a number:

  def go(runtime):
if runtime.id == 1:
  x = int(some_input_field.text)
else:
  x = None
x = runtime.shamir_share([1], Zp, x)
y = x * x
z = runtime.open(y)
z.addCallback(update_output)

Here I guess a text input field in GTK has a text attribute...
Finally, update_output would do:

  def update_output(output):
some_label.text = "Shared number: %d" % output.value

I talked about this with Tomas Toft just the other day, so maybe he
can contribute more to the pseudo-code :-)

There were a slightly tricky issue with the synchronization of program
counters that we had to think about, but now I don't remember the
details. But I know that Tomas has a photo of our blackboard... :-)

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


[viff-devel] GUI programming for Python/VIFF

2009-02-10 Thread Håvard Vegge

Hi!

I'm developing a small application that will use VIFF. Instead of 
inputting values through the command line I would like to create a 
simple graphical interface.


Have anyone experience with such GUI toolkits? Any recommendations?

- I've barely tested PyQt, but it has some dual commercial/GPL license 
that I probably want to avoid.
- Tkinter is the "standard" GUI toolkit for Python, but is reported to 
have a non-native look and feel.
- wxPython is maybe the most popular GUI toolkit for Python, so perhaps 
I give it a try.


Håvard
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk