Stefano Mtangoo 455 Senior Poster

would somebody submit a commercial application for bundling?
;)

Stefano Mtangoo 455 Senior Poster

Hi All,
what is method to get all availabled disk drives and their status. By status I mean whether they are hard disk or CD/DVD or USB? Also how to get list of Drives in *nix?
Thanks a lot

Stefano Mtangoo 455 Senior Poster

Thanks Snippsat for good code but what I'm looking for is the way to get Drives without dialog just as you get files within a folder without a dialog. I want to get all available Drives and know if the drive is USB or CD or HDD
something like this:
C: HDD
D: HDD
E: CD/DVD
F: USB

Thanks for reply

Stefano Mtangoo 455 Senior Poster

Hi all, I have been poking wx document and also google but i havent prevailed. All I need is to get all drives C, D, E etc just like my computer is. What is the trick? Thanks

Stefano Mtangoo 455 Senior Poster

which/what type of project?
Open source / commercial? ;)

Stefano Mtangoo 455 Senior Poster

So in summary (for lazy to read like me), what is the issue? Doesn't work as intended or throws exception? What is the error?

Stefano Mtangoo 455 Senior Poster

I haven't understood what you are trying to do. Make HTML editor? Read HTML? or what? Can you please elaborate more?

Stefano Mtangoo 455 Senior Poster

Is that Linux?
I guess the module installed in non standard path and needed to add .pth file to point to that folder

Stefano Mtangoo 455 Senior Poster

aww, crap. seems like I have to change from Tkinker to wx

beatiful decision that will change your coding ;)
I'm just wxFan

Stefano Mtangoo 455 Senior Poster

not sure what you want but here are tricks I use
Use GetParent function to get parent and store that parent in variable. Then use that variable to call any parent method. For dialog, its parent will be a Frame and by that trick you can call any frame methods from Dialog.

Using Multi class is better for learning and big projects. For small projects keep with one class

Stefano Mtangoo 455 Senior Poster

Pyinstaller is also a binary compiling package for python. It may be easier to use than Py2Exe, but I would highly recommend using py2Exe.

GUI2exe handles them all. You can install them all and choose them on fly ;)

Stefano Mtangoo 455 Senior Poster

If you plan for simple GUI go for TKinter (I don't love it myself).
I will recommend for wxPython, a great GUI with excellent support (even here) and active mailing list. Vast Docs for wxWidgets is added advantage. PyQT is competitor, but Licencing issue turns many off! If you like QT then wait for PySide to mature unless you want to go GPLed

Stefano Mtangoo 455 Senior Poster
database = [('name1','1234'), ('name2', '5678'), ('name3', '9012')]

name = raw_input('Enter username:\n ')

passwd = raw_input('Enter password:\n ')
found = False
for usrname, password in database:
   if((name==usrname) and (password==passwd)):
      print 'Welcome', name
      found = True
      break;

if(not found):
   print 'Invalid password or username'
Stefano Mtangoo 455 Senior Poster

'm trying to make a code for you, but have you realized you use keyword "pass"? which editor/IDE are you using?

Stefano Mtangoo 455 Senior Poster

I did it finally. I have to add another array with label. Also I passed array by reference.
Thanks JRM for challenges and contrib.

Stefano Mtangoo 455 Senior Poster

Use GUI2exe. It have many options on GUI. You can optionally generate setup.py and edit manually to suit your case

Stefano Mtangoo 455 Senior Poster

PIL is not part of Standard Library. Did you install it explicitly?

Stefano Mtangoo 455 Senior Poster

would you post this to codeblocks forum also? There you meet very maker of CB, and other Coders

Stefano Mtangoo 455 Senior Poster

Don't waste time writing and editor or an IDE! Don't reinvent the wheel! Go to the wikipedia list of algorithms, which points to virtually hundreds or thousands of clever algorithms, and implement a few of them in python.

Thanks for pointing that. I was thinking of something one can do and be proud of. Once one writes such a small IDE he can then feel that he have ever done something useful :)

Stefano Mtangoo 455 Senior Poster

so you suggest for me to do with ImageMagick and C++?

Stefano Mtangoo 455 Senior Poster

and GUI2exe if you a lazy like me to use setup.py. Gavana did it for us :)

Stefano Mtangoo 455 Senior Poster

Hello guys
I want to make little application to convert png files to xpm I wonder what is the easiest approach! Load the image in DC and save as xpm? or what?

Thanks!

Stefano Mtangoo 455 Senior Poster

and please tell me the use of

if __name__ == "__main__":
run_service(SERVICE_COMMAND)

This tella python to run the function if the file is run directly and not imported somewhere

Stefano Mtangoo 455 Senior Poster

Mandriva 2010

Stefano Mtangoo 455 Senior Poster

The 'or die " exits from the code when the condition is met.
I don't see an If statement there at all.

Sure, no if!

Stefano Mtangoo 455 Senior Poster

hi thr,

Could u pls tell me how to write the codes..
I tried it out but cant get it updated... in the admin table..
Pls help...
Thanks

Did you try the above trick

Stefano Mtangoo 455 Senior Poster
<?php
if($_POST['btn']=='Update'){
$old_pass=$_POST['opass'];
$new_pass=$_POST['npass'];
if($old_pass==$$new_pass){
$query="UPDATE users set password='$new_pass' where password='$old_pass'";
mysql_query($query);

}
else{
echo "Password Doesn't match!!";
}


?>
Stefano Mtangoo 455 Senior Poster

Then re install the module.
I haven't used PIL but does it go with capita letters PIL or small one?
Try from pil import ....

Stefano Mtangoo 455 Senior Poster

thanks evstevemd

Karibu (Welcome)

Stefano Mtangoo 455 Senior Poster

So, what do you want Python to do for you?

Stefano Mtangoo 455 Senior Poster

Just a technique. Replace variables with form's variable and Update Query according to your table structure

<?php
$pass = $_POST['password'];
$rpass = $_POST['repeatpassword'];
if($pass==$rpass){
	$query = "UPDATE QUERY HERE";
	mysql_query($query);
}

?>
Stefano Mtangoo 455 Senior Poster

how do you import it?
What OS do you have?

Stefano Mtangoo 455 Senior Poster

Create simple Python IDE with Syntax highlighting, Class Browser, Auto complete and Directory explorer

Stefano Mtangoo 455 Senior Poster

Design a file manager with Two Panels Like Krusader in KDE Linux or Total Commander. The File Transfer between two sides should be done via menu (Copy/Cut/Paste), Buttons, Context Menu, Shortcut Keys and Drag and drop.

Additionally you can add FTP functionality Even SSH. Cross Platform should be a buzzword :)

Stefano Mtangoo 455 Senior Poster

Under Linux (Mandriva for me) I use NetBeans. You can go for Eclipse/PDT or Aptana Studio

Stefano Mtangoo 455 Senior Poster

That's just it. This is YOUR brainchild, not mine. I really haven't a clue about what you have in mind (nor do I want one) for the "big picture".

All I am saying is, plan your code so that it is as simple as possible, Annotating functions and classes is helpful if you have to revisit it a year or two later.

That form generator can be expanded to take more arguments such as attributes, etc.
I don't know how fancy you need it or what the end game is.
Maybe if you sat down and did a flow chart outline of what you are attempting might help you?

Writing a bunch of disembodied code without a "roadmap" will make you crazy.

:)

Stefano Mtangoo 455 Senior Poster

Hi all,
Just curious. If I want to write a library to play almost all common audio formats, what do I need to know? an it should be cross platform. I want to implement in C++ library like bass. But that will be possible only if I will be ready to take the pain. So your ideas/contributions will help me weigh the issue

Stefano Mtangoo 455 Senior Poster

Let's say that the form parameters are collected from a configuration form page. The array is generated from that, so the form handler does the dirty work. Your "sanitizing" takes place long before that array shows up to be used as an argument (hopefully).
So using the "KISS" method, the final method looks like this:

#
public function buildForm($actionFilePath='login.php', $Array){
            //test for $actionFile Path, throw error and/or default 
            // test for $Array , throw  error if null or wrong type, etc
           // make the form
          //return the form as a string
         }

your idea seems practical. But could you elaborate more. Do you mean I should have another php file to hold form configurations or what? I'm lost here so elaborate please! :confused:

Stefano Mtangoo 455 Senior Poster

I am not familiar with Code::Blocks but several other members here seem to like it.

If you are running Windows, I know that MS-VC++ is capable of doing everything you mentioned. Stay away from Dev-C++, its debugger leaves something to be desired.

I have no idea about Unix or Linux IDEs though.

Like AncientDragon, I guess this feature will make me have VS if it will love me. Can VS express play well with wxWidgets and SDL + personally made DLLs?

What do you other guys say?

Stefano Mtangoo 455 Senior Poster

Make a cross platform Media player with Player list editor as well as normal button. User should be able to make playlists and edit them as well. Use your favorite GUI toolkit, SQLite3 module and multimedia framework like Snack Audio or Pyglet

Stefano Mtangoo 455 Senior Poster

Vega had nailed a "Starting Python" thread. I though there should be a place for proposing intermediate and advanced projects so that one can have something to do to improve their skills more. Especially for those who don't do alot of math enough to get the challenges of project eura :)

Stefano Mtangoo 455 Senior Poster

First thanks for taking your time to answer to the post

OK, but the constructor seems to be excess baggage if you want the function to take an array anyway.

Yes I might be wrong but my point was that, the array be global to the class because there are other functions that will have to use array like sanitizing, validating et al

What do you propose as alternative to this?

class MyForm{
    private  $formArray;
    //pass array to build a form in form of name=>type eg username=>text to a constructor


/*You are making the array available to the entire class. What is the point of that ? A specific array would need to go to a specific method anyway, so why not just make it a second argument to the function.
Nix this...????  */
    public  function   __construct($postArray) {
        //make the form POST variables available to the class
        $this->formArray = $postArray;
        //print_r($this->formArray);
    }

Hope I have explained my intention

/*Here you setting this function to login.php form the get-go, no flexibility there! What would be better is take in the variable test it, if null set to the default. put the second array argument in and you have a versatile funtion that is simple to use. */
    //construct a form
    public  function  buildForm($actionFilePath='login.php'){
        echo "<form action='$actionFilePath' method='POST' id='loginform'>";
        echo "<table border='1', cellpadding='5'> ";
        foreach ($this->formArray as $name => $type) {
            echo "<tr>
                 <td><input type='$type' name='$name' id='$name' /></td>
                 </tr>";


        }//end foreach

        echo "</table>";
    }



}// end form …
Stefano Mtangoo 455 Senior Poster

Hi All,
Till now I haven't done any serious debugging (Jump to line, blah blah). What I have done so far is read error and try to decode. Now I want to use variables form stack etc. In WingIDE/Python I will click on stack and see variables and what they contain. I tried today with Codeblocks, it was to me like trying to launch a rocket

Is debugging in C++ that harder? How can I see variables, change their values, run to a line etc in C++ Any tutorial on debugging?
Thanks alot

Stefano Mtangoo 455 Senior Poster

I'm retreating for a while.
It seems somehow difficult. I will come back

Stefano Mtangoo 455 Senior Poster

you are right, that is one of the bunch of things in that class.
The class will have to handle all form activities like validating names, birthdays emails, etc.

Why would I want to do that way? well, I want user to define his array of what he needs and then the function will construct login form. If you need two fileds, then pass only the needed array, want gazillion? do the same! you get my point?

This is small thing that class will do. And I want it to be extensible and very generic

Stefano Mtangoo 455 Senior Poster

isn't there a widget for showing dir tree like other toolkits in other languages?

Stefano Mtangoo 455 Senior Poster
$form->buildForm('inc.form.php');

Specifies ACTION in the form

Stefano Mtangoo 455 Senior Poster

here is the code to do a test. The above code is in the include file

<html>
    <head><title>Test Login Form</title></head>

    <body>
        <?php

            require('inc.form.php');
            echo '<h1>Register</h1>';
            $formArray = array('username'=>'text', 'password'=>'password', 'submit'=>'submit');
            //print_r($formArray);
            $form = new MyForm($formArray);
            $form->buildForm('inc.form.php');
        ?>


    </body>



</html>
Stefano Mtangoo 455 Senior Poster

You could have a slight problem with id='$name' name='$name' . Sometimes it's important to have the same 'name' for radio buttons, or even the same arrayname for textboxes (etc) that you WANT to be placed into an array. Obviously, each individual form widget MUST have different 'id' values.

Don't know if I'm being clear or not. In other words, 'id' not always equal to 'name'.

Sure, they must be different. I did name=id to make array simple. If I had to make another array containing the ids it would be complex. But If there is a way to do that, I will be glad to learn :)

Stefano Mtangoo 455 Senior Poster

My point was that THERE IS NO ARRAY defined in the original, therefore the constructor has nothing to output. You say it works, I guess you must have it defined somewhere, then.
In the the first post you said it DIDn't work, but now you need labels?
That' s easy, just use a label tag before the input tag

<td><label FOR ='$name'> $name </label><input type='$type' name='$name' id='$name' /></td>

OOps!
you are right! I was not clear to the post. Sorry for that.
Here is the thing. The array is defined when using the class I will put the code a bit later. The problem is (Which sadly I failed to address well) I want the label to be part of array. In fact I want the whole form to be constructed dynamically so it will be flexible.

I hope I'm clear now