Building tkinter on Windows

2013-09-08 Thread Westley Martínez
Hello.  Can anyone tell me how to build tkinter on Windows?  I've downloaded 
the source, ran Tools/buildbot/external.bat to build the external dependencies. 
 I copied tcl85g.dll and tk85g.dll to PCBuild.  I built the Visual Studio 
solution.  Everything built fine without errors.  Everything seems to work 
except tkinter.  It says:

Traceback (most recent call last):
  File "", line 1, in 
  File "...\cpython-idle\lib\tkinter\__init__.py", line 36, in 
from tkinter import _fix
  File "...\cpython-idle\lib\tkinter\_fix.py", line 65, in 
import _tkinter
ImportError: DLL load failed: The specified module could not be found.

I'm thinking I didn't put the DLLs in the right place, but I don't have any 
idea where to put them and Google isn't helping.
-- 
https://mail.python.org/mailman/listinfo/python-list


Logical error in filling QTableWidget and filling all of nodes

2013-09-08 Thread Mohsen Pahlevanzadeh
Dear All,

I have the following code (PyQt):

/
searchFrameObject.tableWidget.setRowCount(rowCounter)
searchFrameObject.tableWidget.setColumnCount(5)

for row in range(rowCounter):
for column in range(5):
for result in query:

item = QtGui.QTableWidgetItem(_fromUtf8(result.name))
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column,item)

#item = QtGui.QTableWidgetItem(String(result.bought_price))
#item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
#searchFrameObject.tableWidget.setItem(row,column+1,item)

#item = QtGui.QTableWidgetItem(result.bought_date)
#item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
#searchFrameObject.tableWidget.setItem(row,column+2,item)

item = QtGui.QTableWidgetItem(result.stock)
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column+3,item)

item = QtGui.QTableWidgetItem(result.minimum_bound)
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column+4,item)


When i search in DB, i print result.name or print result.stock ,
everything is OK. But when i import them into QtableWidget i see just
node result.name addeed to widgets. (all of nodes filled from
result.name)

My Question is , How i fill rows and columns with my fields?


Yours,
Mohsen

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing resource data files and finding them

2013-09-08 Thread Ben Finney
Ben Finney  writes:

> I will need to change both the build configuration and the application
> code, so that instead it allows the resource files to be installed to
> an appropriate location on the target system, and seeks the data files
> in the correct location when run later.

I've used an ugly hack to work around this problem:

* Patch the ‘MANIFEST.in’ and ‘setup.py’ to omit all mention of the
  resource files. This makes the Python Distutils simply omit the
  resource files and not install them at all.

* Add a series of rules to the package builder to explicitly install the
  resource files to a temporary build location. Make sure these rules
  work for the multiple binary packages and for multiple builds.

* Install the resource files for each package to an FHS-compliant
  location outside the Python package.

* Make a symlink within each installed package to the resource location
  for the package.

That works for now. It's ugly and a maintenance burden, though: I would
hate to need to do this for resource files in every Python package.

> I had hoped to use Python's standard library (Distutils? Distribute?
> Something else?) to access the resources once installed to the correct
> location. This needs to allow the choice of location to be made at
> install-time, but discovered by the application at run-time.

Ideally I wouldn't need to subvert Distutils, but could somehow tell it
what I need and have it record the install-time decisions for the
run-time application's needs.

I'm still hoping there is a standard-library way to do this. Please let
me know.

-- 
 \ “You are welcome to visit the cemetery where famous Russian and |
  `\Soviet composers, artists, and writers are buried daily except |
_o__)   Thursday.” —Russian orthodox monastery, Moscow |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread llanitedave
I capitalize "Free" to avoid confusing it with "free as in beer".

On Sunday, September 8, 2013 3:01:58 AM UTC, Ben Finney wrote:
> Aaron Martin  writes:
> 
> 
> 
> > Hi, I am thinking about getting a software but it requires python, so
> 
> > that brought up a few questions. Is it safe do download python, and
> 
> > does it come with spam or advertisements?
> 
> 
> 
> Python is free software, meaning that every recipient is free to improve
> 
> it and redistribute the result.
> 
> 
> 
> https://en.wikipedia.org/wiki/Free_software>
> 
> 
> 
> Free software rarely has the problems you describe – spam and
> 
> advertisements – and never has them for long, because those problems are
> 
> quickly improved (by eradicating the annoying problem), and the improved
> 
> version becomes what people share.
> 
> 
> 
> > If it doesn't then should I get the latest version?
> 
> 
> 
> The latest stable version is Python 3.3, and this version is strongly
> 
> recommended for people who will be developing with Python.
> 
> 
> 
> But you say that you are getting Python because you have some other
> 
> program that requires Python. Which version of Python does it require?
> 
> Download and install the latest version that is supported for the
> 
> program you are wanting to use.
> 
> 
> 
> > I mostly want to know if it is safe to download, because most of the
> 
> > time downloading free stuff off the internet comes with spam and all
> 
> > that, so I want to know if I can trust downloading it.
> 
> 
> 
> Ah, your experience is with zero-cost non-free software. Non-free
> 
> software is prone to have spam and advertisements, and many other
> 
> problems that arise from disrespect for the recipient's freedom. So your
> 
> caution is well advised.
> 
> 
> 
> Know that free software respects your freedom, and Python is free
> 
> software.
> 
> 
> 
> https://www.fsf.org/about/what-is-free-software>
> 
> 
> 
> Welcome, and good fortune to you in using Python!
> 
> 
> 
> -- 
> 
>  \ “I was trying to daydream, but my mind kept wandering.” —Steven |
> 
>   `\Wright |
> 
> _o__)  |
> 
> Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Weighted choices

2013-09-08 Thread Cameron Simpson
On 08Sep2013 20:21, Dennis Lee Bieber  wrote:
|   However, I would not use a dictionary for this. An ordered list should
| work better... for small samples a list containing repeats (by weight) of
| each choice, and then use a random integer whose range is 0..len(list)-1
| would suffice.
| 
| choices = ["apple", "apple", "apple", ..., "kiwi", "kiwi" ]

Scales badly as soon as the weights get even slightly big (or high res).

|   For longer lists, storing a tuple with the accumulating weight, and
| scanning from the beginning
| 
| choices = [(10, "Apple"), (10+20, "Pear"), (10+20+15, "Banana")... ]
| 
| generate random integer in the range of the sum of the weights, and accept
| the last tuple whose first element is less than the integer.

Search it with the bisect module, not linearly!

Cheers,
-- 
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread Terry Reedy

On 9/8/2013 9:29 AM, Wolfgang Keller wrote:

Definitely get the latest version (currently 3.3, soon 3.4). Python
keeps getting new features and improvements.


Python scripts or applications might not be compatible with Python 3.x
and require 2.x instead.


And the other way around.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Weighted choices

2013-09-08 Thread Antoon Pardon

Op 08-09-13 04:12, Jason Friedman schreef:

choices = dict()
choices["apple"] = 10
choices["pear"] = 20
choices["banana"] = 15
choices["orange"] = 25
choices["kiwi"] = 30

I want to pick sets of fruit, three in a set, where the chance of
selecting a given fruit is proportional to its weight.  In the example
above, pears should appear twice as often as apples and kiwis should
appear twice as often as bananas.


Just a small question. Is a set of three bananas an acceptable outcome?

--
Antoon Pardon

--
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread Chris Angelico
On Mon, Sep 9, 2013 at 2:08 AM, Charles Hottel  wrote:
> I think this article is relevant althought the code examples are not Python
> but C:
>
> http://cm.bell-labs.com/who/ken/trust.html

That is quite true, and yet not truly helpful here :) It's like
pointing out that we could be being fed false information, and then
suggesting that The Matrix is technically possible. Once you start
distrusting to that level, you become paranoid to a point that's
inappropriate to all but the most critical situations. I'd accept and
maybe even recommend that sort of paranoia if you're running a nuclear
power station, or an automated weapon system capable of firing
missiles that destroy the planet, or a bank that holds everyone's
money. For the average Joe, there's no point panicking.

Also: That hack works beautifully when there's precisely one C
compiler. In today's world, there are many (well known ones like gcc,
clang, MS Visual Studio (whatever the compiler from that is called),
and a bunch of lesser-known ones as well), and it's pretty easy to
just grab a different compiler and build. The chances that your code
will be falsely compiled by TWO compilers would have to be
infinitesimal, and you needn't stop at two. Since many people build
(to take one example) gcc from source, using an old version of gcc,
the hack would have to be propagated to all current gcc builds in some
way - you can't simply build once and install the binary as the
official C compiler, not in today's distributed society. (If you're
truly paranoid, you might believe that gcc has had the hack in it
since its inception. But some people build gcc using other compilers,
too.)

If you can't trust any code you didn't write yourself, you're left
with Rene Descartes' line "I think, therefore I am" - it's impossible
to prove anything else, since you can't trust your senses. So go
ahead! Distrust everything and use nothing. Or accept that, even if
you're the target of a huge conspiracy, it doesn't even matter,
because life still goes on :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread Charles Hottel

"Steven D'Aprano"  wrote in message 
news:522c6e4e$0$29988$c3e8da3$54964...@news.astraweb.com...
> On Sat, 07 Sep 2013 21:04:59 -0600, Michael Torrie wrote:
>
>> As for trusting python in general, I do trust the python developers, but
>> recent NSA revelations call just about all aspects of computing, trust,
>> and privacy into doubt.
>
> "Recent" revelations? Where have you been for the last, oh, 20 odd years?
>
> Remember when people who talked about Carnivore and Echelon were
> considered in tin-foil hat territory? I do.
>
> I think it was Paul Krugman who talks about the one thing worse than
> being wrong is being right too soon. In context, he's referring to the
> Bush administration's adventures in Iraq, and how those who were right a
> decade ago are still routinely ignored even after being proven right,
> while the Very Serious People who were utterly, obviously wrong are still
> feted as experts. The same applies to the surveillance society. This
> didn't just appear overnight. You don't build programmes the size and
> complexity of PRISM, Tempora, Stellawind, X-Keyscore, Dropmire, and no
> doubt others that we still don't know about, overnight.
>
> When it comes to NSA spying, before Edward Snowden, there were these
> other guys:
>
> http://www.usatoday.com/story/news/politics/2013/06/16/snowden-whistleblower-nsa-officials-roundtable/2428809/
>
>
> And if you think it's just the NSA, you *really* haven't been paying
> attention. From 2005:
>
> http://www.noplacetohide.net/
>
>
>
> -- 
> Steven

I think this article is relevant althought the code examples are not Python 
but C:

http://cm.bell-labs.com/who/ken/trust.html


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread Wolfgang Keller
> Definitely get the latest version (currently 3.3, soon 3.4). Python
> keeps getting new features and improvements.

Python scripts or applications might not be compatible with Python 3.x
and require 2.x instead.

Sincerely,

Wolfgang
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can I trust downloading Python?

2013-09-08 Thread Steven D'Aprano
On Sat, 07 Sep 2013 21:04:59 -0600, Michael Torrie wrote:

> As for trusting python in general, I do trust the python developers, but
> recent NSA revelations call just about all aspects of computing, trust,
> and privacy into doubt.

"Recent" revelations? Where have you been for the last, oh, 20 odd years?

Remember when people who talked about Carnivore and Echelon were 
considered in tin-foil hat territory? I do.

I think it was Paul Krugman who talks about the one thing worse than 
being wrong is being right too soon. In context, he's referring to the 
Bush administration's adventures in Iraq, and how those who were right a 
decade ago are still routinely ignored even after being proven right, 
while the Very Serious People who were utterly, obviously wrong are still 
feted as experts. The same applies to the surveillance society. This 
didn't just appear overnight. You don't build programmes the size and 
complexity of PRISM, Tempora, Stellawind, X-Keyscore, Dropmire, and no 
doubt others that we still don't know about, overnight.

When it comes to NSA spying, before Edward Snowden, there were these 
other guys:

http://www.usatoday.com/story/news/politics/2013/06/16/snowden-whistleblower-nsa-officials-roundtable/2428809/


And if you think it's just the NSA, you *really* haven't been paying 
attention. From 2005:

http://www.noplacetohide.net/



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list