4,305 Posted Topics

Member Avatar for vegaseat

There are some pretty fancy things you can do with strings in Python. You can append, convert, justify, join, split, slice, and list selected files of a folder. I just give you a small sample here.

Member Avatar for vegaseat
1
377
Member Avatar for vegaseat

This is an application of the Python Image Library (PIL) and shows you how simple it is to do pixel math on an image.

Member Avatar for vegaseat
2
9K
Member Avatar for Dark_Omen
Member Avatar for Dark_Omen

Greetings Dark! I downloaded Ruby. The sample codes look a little like a mix of Python, Java and C. Got the FreeRide IDE going, cute, but nothing shows up in the output window after running the code. Is there a trick?

Member Avatar for Dark_Omen
0
234
Member Avatar for vegaseat

This code gets the local time from your computer, formats the date and the time and displays the result. Does not include the bavarian time measurement of how many steins you have finished since you got up in the morning.

2
180
Member Avatar for vegaseat

One more look at BCX basic code to show the qbasic programmers how they can modernize. This shows a function that converts an integer value to a binary string. Notice that with BCX basic you need to declare your variables. Makes the code a little easier to read too. Variable, …

0
462
Member Avatar for vegaseat

This shows you how to create a Windows GUI program in BCX basic and embed the Media Player in the form. It will give you a fully functional player with a 30k executable size for your MP3 files. The needed header files and library files are included in the BCX …

0
236
Member Avatar for vegaseat

New to me, but MS InternetExplorer does have COM support you can access from basic code. I had to test this out and make it work. We are using BCX basic, one of the successors to Qbasic.

0
193
Member Avatar for vegaseat

Another look at BCX basic. Here we use COM support to manipulate Excel. In other words, from within the basic code we are entering a few numbers into the Excel spreadsheet and add them up. Of course you can do much more powerful stuff. With COM support you can also …

0
156
Member Avatar for vegaseat

Nothing new, but something for the neophyte to ponder. Some of the functions (algorithms) used by STL containers can be applied to a normal array to do inane things like copying, displaying, finding max/min, reversing, replacing, searching, shuffling, sorting, summation. This can really simplify your code.

Member Avatar for vegaseat
3
359
Member Avatar for vegaseat

I just had to do this to see how it would look like in the code field. This small prime number generator is written in BCX basic, a mildy more modern basic than Qbasic. With BCX basic you can throw in C and assembler code and it would actually compile …

Member Avatar for vegaseat
0
110
Member Avatar for vegaseat

You probably have seen those message snakes following the cursor on a web page. Well, the javascript code is not too complex, so let's look at it ...

0
113
Member Avatar for vegaseat

With the help of BCX I managed to create some C++ code that will allow you to send text to your printer and specify the font and other things. Play around with the options to suit your own needs. I have to admire the genius behind BCX, even though it …

Member Avatar for cybercode
1
328
Member Avatar for vegaseat

Sooner or later a Csharp snippet had to appear. This one builds a form containing a set of buttons. A bitmap drawing area is used to draw a series of circles with random color, radius and center location. Your creation can be saved as a jpeg image file. You can …

Member Avatar for borjelewin
0
3K
Member Avatar for vegaseat

Short little sound files of chicken, horses, dogs, cars, trains and other annoying things is the realm of the wave file (.wav). These are easy to play and guaranteed to confuse grandpapa. Again, we are using Windows' sound workhorse winmm.lib file. Ze function this time is PlaySound(). Here is ze …

Member Avatar for danibootstrap
1
224
Member Avatar for vegaseat

Many of you know how I like to use sound to make the old computer box more interesting. The midi file packs a lot of neat instrumental music. It is very simple to play, even in a console application, using the winmm.lib file that comes with just about any Windows …

Member Avatar for evilsilver
0
242
Member Avatar for vegaseat

You can have fun and learn something too. Not too much fun though! Here we take a lighthearted look at C++ string, various ways to assign a string and substring, spell forward and reverse, find characters and substrings, append, insert, replace, remove characters, separate a sentence into words and more.

2
199
Member Avatar for 1o0oBhP
Member Avatar for vegaseat

This Delphi procedure sends the text contained in a multiline editbox (memo in Delphi lingo) to a printer. The font and font size can be specified.

0
247
Member Avatar for 1o0oBhP
Member Avatar for bumsfeld
0
632
Member Avatar for vegaseat

Just to give you an idea what Delphi can do, here is a plot of the ever popular sin(x). I have put enough information into the code comments so you can build the form. The PaintBox Paint Event takes care of the plotting.

0
972
Member Avatar for vegaseat
Member Avatar for vegaseat

The Standard Template Library (STL) vector is tempting. The burden of dimensioning an array is removed, and there are many wonderful functions to explore. The learning curve is a little steep, it will make your head swell, but in the end it's all worthwhile. Take a look at some of …

Member Avatar for vegaseat
1
178
Member Avatar for vegaseat

Let's expand the decimal to binary converter to include, amongst others, octal and hexadecimal conversions. Also shows how to exert some input control. Simple stuff!

1
185
Member Avatar for vegaseat

Let's say you worked in the White House and had to keep two lists, one for the friends and one for the enemies. The boss came to you and said: "The Almighty talked to me out of a burning bush last night, telling me that I shall make my enemies …

2
191
Member Avatar for vegaseat

Another experiment with the Standard Template Library (STL). This time we are taking a look at map. Map is a Sorted Pair Associative Container (a mouthful). The pair is -- const Key, Data --, where Key has to be unique. It is Key that is sorted. In this code sample …

1
169
Member Avatar for vegaseat

Using the C++ Standard Template Libraries (STL) can be easy, once you know how to do it. No need to putz around with doubly linked lists anymore! Here is code showing how a STL list allows you to add, insert, remove, sort, splice, merge, display, and clean-out-duplicate strings.

2
164
Member Avatar for vegaseat

Get simple information like serial number, bytes/sector, sectors/cluster, free and total disk space of your hard drive using Windows API calls.

Member Avatar for sytheron
2
154
Member Avatar for vegaseat

What is so easy to do in HTML gets quite involved in C. Once you learn to look past the standard GUI overhead it becomes more obvious. This example shows the effect of the mouse cursor moving across a label by changing foreground and background colors.

0
212
Member Avatar for vegaseat

This program shows how to display a JPEG (also GIF,BMP,WMF etc.) image using some Windows Graphical User Interface C code. The program uses the uuid.lib file that comes with many C compilers.

Member Avatar for ashutosh_singh
2
1K
Member Avatar for vegaseat

This snippet shows how to draw a red circle on a Windows form. Original code via BCX, modified to compile with Dev C++. The GUI code looks a little complex. Gets simpler, once you get past the required overhead. For those who need some hand holding with the Dev C++ …

0
2K
Member Avatar for vegaseat

Use a Windows API call to add some color to your text output. A rewrite of an earlier C++ snippet for the C crowd.

2
566
Member Avatar for vegaseat

The continued fraction expansion gives us the answer to life's most persistent questions, like what is sin(x) or even tanh(x). This surprisingly short code allows you to estimate SIN, COS, TAN, EXP, SINH, COSH and TANH fairly accurately. Careful, this code is not for the usual TV crowd! You should …

Member Avatar for bumsfeld
2
193
Member Avatar for Mostafaib
Member Avatar for Ally89

You are almost there, you need to indent properly to keep your statement blocks together ... [code=python]def load_products(filename): #filename = 'C:\Users\User\Desktop\cssetute\products.txt' f = open(filename, 'r') dictionary = {} for line in f.readlines(): list1 = line.strip().split(',') tuple_list = [] for item in list1: line = line.rstrip() if ':' in item: text, …

Member Avatar for Ally89
0
132
Member Avatar for freon73

Could you please give us some more details. Like operating system, type of network and so on.

Member Avatar for Tech B
0
196
Member Avatar for Rete

Python has no goto statement. In C as in Java a goto should only be used in special cases, like breaking out of a series of nested loops. Here is a Python workaround ... [code=python]# setting a binary flag will work, similar to a goto in C loopsDone = False …

Member Avatar for scru
0
769
Member Avatar for broberts_az

You need to write the value/text you are getting to the file: target.write(self.transferArea.GetValue())

Member Avatar for broberts_az
0
199
Member Avatar for Lingson

The other GUI toolkit that works with Python 3.1 and can display a number of image formats including .jpg is PyQT. There is a note about getting the Windows installer that Henri left at: [url]http://www.daniweb.com/forums/post922737-26.html[/url] Here is a sample code in simple (no class) style ... [code=python]# display an image …

Member Avatar for vegaseat
0
1K
Member Avatar for tarun02kumar

[QUOTE=bumsfeld;959915]Extension .pyd is used for C compiled library files for Python.[/QUOTE]Files with extension .pyd are library files for Python and are accessed with the import statement. I would recommend not to use this extension for private files that are not specifically structured Python library files.

Member Avatar for tarun02kumar
0
433
Member Avatar for mn_kthompson

You can snoop around Python code with this ... [code=python]import dis def myfunc(): a = 2 b = 3 print("adding a and b and 3") c = a + b + 3 if c > 7: return c else: return None # this disassembles the above function's code dis.dis(myfunc) """my …

Member Avatar for vegaseat
0
275
Member Avatar for EAnder

To colorize words you are asking too much of good old Tkinter. You most likely need to got with the wx.StyledTextCtrl() widget. This STC control wraps the Scintilla editor component so it will work with wxPython. Could be that something like this is available for Tlinter.

Member Avatar for vegaseat
0
821
Member Avatar for bumsfeld

I prefer to know where functions came from, so I would use the namespace alternative ... [code=python]import math y = math.sin(1) + math.cos(1) [/code]If you use ... [code=python]from math import sin, cos y = sin(1) + cos(1) [/code]... in the hope that only sin and cos are imported, you are …

Member Avatar for Stefano Mtangoo
0
117
Member Avatar for stvrich

No, the line numbers are not part of the code. They are added by DaniWeb for your convenience. Click on (Toggle Plain Text), if you want to see the code without them, or you want to copy and paste code into your editor (in your case the IDLE editor). If …

Member Avatar for stvrich
0
240
Member Avatar for mahela007

Maybe a little example will help ... [code=python]import sys args = sys.argv print(args) print( "Source file: %s" % args[0] ) # use any of these arguments in your code print( "Argument one: %s" % args[1] ) print( "Argument two: %s" % args[2] ) """ my output after saving this code …

Member Avatar for mahela007
0
629
Member Avatar for M A

Try something simple like this ... [code=python]mylist = [ 0.00024064097412677081, 0.0010840802387205584, 0.003607376872954593, 0.0078014804983401742, 0.013657631815844617 ] t = open(r'my_powerD2.csv', 'w') for item in mylist: t.write(str(item)+'\n') t.close() [/code]

Member Avatar for M A
0
76
Member Avatar for mahela007

The EOF is a marker byte that is at the end of any file. If I remember my C days, it is physically -1 or such thing. It is significant to any computer language that reads/writes files. In Windows EOF is generated with key combination ctrl-z and in Linux with …

Member Avatar for bumsfeld
0
343
Member Avatar for utefan001

[QUOTE=utefan001;953684]When dealing with big numbers (over 100,000 digits). I find str(myint) too slow. The code below takes my machine 8 seconds. Doing a quick test in java takes 0.186 seconds [code=python] import time #**setup part** i = 0 myint = 1 while i < 100000: i = i + 1 …

Member Avatar for vegaseat
0
275
Member Avatar for pynoc

Since you have Windows, try the PyScripter IDE from: [url]http://pyscripter.googlepages.com/[/url] It has the usual run triangle icon, and you can run the code with or without saving the file. This IDE is an executable file written with Delphi, it is free (if you like it, donate a few bucks) and …

Member Avatar for woooee
0
133
Member Avatar for Ancient Dragon

Do not meddle in the affairs of dragons, for them you are crunchy and good with ketchup.

Member Avatar for Wasser
1
232

The End.