1,075,996 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by WolfShield Contributing to Articles being Marked Solved

@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
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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 know them (a classmate; friend; etc) you would say "tu", and that kind of thing extends to other words (we, they, etc.). So, another good question is do you know another language or have someone working with you who does? It will be key to the translation aspect of your program.

My last piece of advice is this: the Daniweb community is big on doing your own work. We (as a community) are great at answering questions and helping out on anything you are confused or stumped on, but we like to see your code, your research, and your specific problem/question(s). I know of many people who will not respond if they do not see you really try at it and have (at least some, even non-working) code to show. We're not trying to be jerks or picky, we just know that you don't learn programming by having someone else do all your thinking for you. Programming is nothing more than a tool to express your thoughts and ideas.

Sorry for such a long post, I can get carried away sometimes. :) I hope at least some of this has been helpful and/or informative for you (if you've read down this far). If you post up some code (or need some help getting started with the code) and a question we will help you out as much as we can. Best of luck friend,

  • WolfShield
WolfShield
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

The one thing I dislike about Java: repeating yourself.

- WolfShield

WolfShield
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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

WolfShield
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0

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

WolfShield
Posting Whiz in Training
258 posts since Oct 2010
Reputation Points: 28
Solved Threads: 6
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.0730 seconds using 2.52MB