WolfShield 32 Posting Whiz in Training

Hello Jake 1,
While I don't have much game programming experience I can tell you about PyGame. It has a lot of components for GUI games, but I'm sure you can make text-based games with it as well. At a very minimum it will give you a more game-based place to look for the documents you said you wanted.

If you are looking at game programming in the future, if that is something you think you would like to do, I would also point you towards Unity 3D. A good buddy of mine has programmed in it for several years now and really likes it. It is simple, powerful and has a free version. You have the choice of programming in three languages: UnityScript (JavaScript), C# or Boo (Python-like).

I once started a text based game in python, never finished it but as far as advice I can give you on that, a thorough understanding of the basics is essential. Your basic print and input, functions, switch-cases, lists and classes are the places to start, you will use them constantly. Also, you should learn very well how to use multiple source files in your application; it will help exponentially in organization and simplifying your source code. A structure setup I would suggest is a main file that will run your whole game and a file for each level/chapter/story-line change/whatever you base your game on.

Another piece of advice I can give if you want to save and store game …

ddanbe commented: Good answer! +14
WolfShield 32 Posting Whiz in Training

@Varunkrishna
It doesn't translate exactly? What do you mean by that? Does the code give any error(s)? What do the text files you are having a problem with look like?

WolfShield 32 Posting Whiz in Training

Okay,
If you want help on the GUI, I use wxPython (based on wxWidgets), so that's most of what I know GUI-wise. But there are other people here who can help you with Tkinter (I assume you're using based on original post).

If you have a specific question, just post up the code you have so far and your question.

Sincerely,

  • WolfShield
WolfShield 32 Posting Whiz in Training

Oh boy,
This may be a long winded post.

First off, I would love to know a little more about you personally. Such as: how long have you been programming; how long in python; is this program for school, personal, or other; what are your goals for this program? Of course you don't have to answer these, they just may help in my answering as well as getting to know a fellow Daniweber a little better. :)

First thing I would do is write out the steps. For this program there are very few general steps:
1) Upload file
2) Convert file
3) Save file

Pretty simple.

My next piece of advice is to work on the back-end code first. That is, write the code that will open the file, read it, convert it and save it first. The GUI is really only for ease-of-use for the user, what really makes the program work is the important part. After that you can make it pretty. :)

Another thing I would say about your particular program that I think will be difficult is converting the file to another language. Some things won't be too hard, like (English to Spanish): Hello -> Hola. But other things can get complicated. For instance, in English we simply say "you". But in Spanish if you are talking to someone you want to show respect to (someone you don't know; a professor; an elderly person; etc.) you say "usted", but if you …

WolfShield 32 Posting Whiz in Training

Hello robinlrandall,
Here is a simple notepad program I wrote a while back in wxPython. If you have any questions on it I would be happy to answer them.

  • WolfShield

    import wx

    class Notepad(wx.Frame):

    def __init__(self, *args, **kwargs):
        super(Notepad, self).__init__(*args, **kwargs)
    
        self.InitUI()
    
    def InitUI(self):
    
        menubar = wx.MenuBar()
    
        fileMenu = wx.Menu()
        fileNew = fileMenu.Append(wx.ID_NEW, 'New', 'New document')
        fileOpen = fileMenu.Append(wx.ID_OPEN, 'Open', 'Open a saved document')
        fileSave = fileMenu.Append(wx.ID_SAVE, 'Save', 'Save this document to hard drive')
        fileSaveAs = fileMenu.Append(wx.ID_SAVEAS, 'Save As', 'Save this document under a new name')
        fileMenu.AppendSeparator()
        fileExit = fileMenu.Append(wx.ID_EXIT, 'Exit', 'Exit application')
    
        editMenu = wx.Menu()
        editCut = editMenu.Append(wx.ID_CUT, 'Cut', 'Cut selected text')
        editCopy = editMenu.Append(wx.ID_COPY, 'Copy', 'Copy selected text')
        editPaste = editMenu.Append(wx.ID_PASTE, 'Paste', 'Paste selection from clipboard')
    
        helpMenu = wx.Menu()
        helpAbout = helpMenu.Append(wx.ID_ABOUT, 'About', 'About PyPad')
        helpHelp = helpMenu.Append(wx.ID_HELP, 'Help File', 'The Help File')
    
        menubar.Append(fileMenu, '&File')
        menubar.Append(editMenu, '&Edit')
        menubar.Append(helpMenu, '&Help')
        self.SetMenuBar(menubar)
    
        self.Bind(wx.EVT_MENU, self.OnNew, fileNew)
        self.Bind(wx.EVT_MENU, self.OnExit, fileExit)
        self.Bind(wx.EVT_MENU, self.OnCut, editCut)
        self.Bind(wx.EVT_MENU, self.OnCopy, editCopy)
        self.Bind(wx.EVT_MENU, self.OnPaste, editPaste)
    
        self.text = wx.TextCtrl(self, 1000, size=(-1, -1), style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER)
    
        self.SetSize((300, 200))
        self.SetTitle('PyPad v0.1')
        self.CreateStatusBar()
        self.Centre()
        self.Show(True)
    
    def OnNew(self, e):
        self.text.Clear()
    
    def OnExit(self, e):
        self.Close()
    
    def OnCut(self, e):
        self.text.Cut()
    
    def OnCopy(self, e):
        self.text.Copy()
    
    def OnPaste(self, e):
        self.text.Paste()
    

    def main():

    ex = wx.App()
    Notepad(None)
    ex.MainLoop()
    

    if name == 'main':
    main()

WolfShield 32 Posting Whiz in Training

The one thing I dislike about Java: repeating yourself.

- WolfShield

WolfShield 32 Posting Whiz in Training

In Java, you have to have a class that is the same name as the file name, or it gives
an error.
So, if your file is called 'chartest.java' you need to have a class named 'chartest'.
Try that and let us know what happens.

- WolfShield

WolfShield 32 Posting Whiz in Training

What IDE are you using?
I ran it in NetBeans and it worked. I only changed the code a little.
The code I used left out the 'class ReverseWord' and just used the file
name class (I called it two.java):

import java.util.Scanner;

public class two {
        public static void main(String args[]) {
            Scanner myScanner = new Scanner(System.in);
            char c1, c2, c3, c4;
            c1 = myScanner.findInLine(".").charAt(0);
            c2 = myScanner.findInLine(".").charAt(0);
            c3 = myScanner.findInLine(".").charAt(0);
            c4 = myScanner.findInLine(".").charAt(0);
            System.out.print(c4);
            System.out.print(c3);
            System.out.print(c2);
            System.out.print(c1);
            System.out.println();
        }
}

It works like a charm.

- WolfShield

WolfShield 32 Posting Whiz in Training

I just ran the code in the IDLE and it worked just fine. No errors.
I am running Windows Vista, and I used Python 2.7.1

- WolfShield

VulcanDesign commented: Thanks for the help! +2
WolfShield 32 Posting Whiz in Training

Hmm,
13. I was pretty sure I would score higher than that.... I guess I'm more quirky
than Psychopathy.

People say my behavior is like Jack Sparrow or Tony Stark. Haha, yeah, I'm fun! :)

- WolfShield

WolfShield 32 Posting Whiz in Training

If I have this right, you want to have a menu and then another menu, ect.
e.g.: File->Open->New->Red Window

If that's the case you just need to assign the menu(s) or menu item(s) to the original
menu item.

e.g. (Sorry if this compiles with errors, I just typed is out without running it):

JMenu fileMenu = new JMenu("File");
JMenu fileOpen = new JMenu("Open");
JMenu openNew = new JMenu("New");
JMenuItem newRedWindow = new JMenuItem("Red Window");

// Now add it to each other
// Adding: newRedWindow to openNew, openNew to fileOpen, fileOpen to fileMenu
openNew.add(newRedWindow);
fileOpen.add(openNew);
fileMenu.add(fileOpen);

Hope this is what you are looking for!

- WolfShield

toferdagofer commented: great advice +1