r/programmingrequests • • Jan 31 '16

I wrote a simple program that generates a random sentence, but I could need help with the GUI part.

http://pastebin.com/trY7FWhu

here's the thing I made. I recently learned just a little bit of Python (which I, editing here, should have probably mentioned in the title), and at some point I sort of stopped programming and just ... added to this.

Now, GUIs are arcane stuff for me. Could I humbly request someone to write a program for me that shows the randomly generated sentence in a window with a button to generate a new sentence? Nothing fancy otherwise.

Oh, and you should totally look at those sentences, that thing can be hilarious.

2 Upvotes

7 comments sorted by

2

u/NoG5 May 01 '16

I ported it to c# and made it a WPF project WPF is pretty flexible with how the UI looks image, download

1

u/[deleted] May 01 '16

Say what, that's totally awesome! I didn't think much more would come of this, thank you!

Guess that also solves that randomness problem?

1

u/NoG5 May 02 '16

did the php version have random problem? never tested it but in the c# version i only used one instance of the Random class so should be pretty random

1

u/[deleted] May 02 '16

Your version seemed pretty random to me (while I tested it extensively, I'm easily entertained :) ).

Somewhere else someone told me my Python version needed a rewrite if I wanted true randomness in an application, sadly I can't say what was wrong with it. Something about one outcome always being the same or the like, maybe it has something to do with the nested random.choices?

2

u/NoG5 May 02 '16

i know in c# if i do someting like

int nr1 = new Random().Next(9);
int nr2 = new Random().Next(9);

nr1 and nr2 will proberly be the same as its a new random object eatch time and it uses the system time as its seed value for randomness

but if i use the same random object like this

Random rand = new Random();
int nr1 = rand .Next(9);
int nr2 = rand .Next(9);

they wont be the same (well they may be it's random) i guss someting like that may have been the problem that they were all using the system time for the random seed value and then made the same number due to everything running fast at the same time

1

u/[deleted] Mar 16 '16

If someone can re-write in java I could do the GUI.

1

u/green-is-my-friend Sep 08 '22

Well since you said nothing fancy. You can use your code as is with a run button like this https://py3.codeskulptor.org/#user307_o303rR2sXg_0.py