I'm kind of new at this:
My app works great in Linux, where I developed it. I'm trying to port it to win7 before making it an exe (the school psych wants to use it on her computer). One of the functions of the app is to change the font size in response to an event (in this case, the user presses a button).
Here's the code:
if countfinal == 1:
on_start = time.time()
ot.append(on_start)
self.welcome.SetLabel("Timing On Task Event")
self.label_directions.SetLabel("Timing On Task Event")
self.SetBackgroundColour(wx.GREEN)
on.append(1)
font = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.DEFAULT, wx.FONTENCODING_SYSTEM)
self.label_directions.SetFont(font)
self.save_quit.Enable(False)
Windows 7 throws up this error:
Traceback (most recent call last):
File "time.py", line 131, in time_event
font = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.DEFAULT, wx.FONTENCODING_SYSTEM)
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 2081, in __init__
_gdi_.Font_swiginit(self,_gdi_.new_Font(*args, **kwargs))
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src \msw\font.cpp(560) in wxNativeFontInfo::Se
tWeight(): unknown font weight
I've been reading that it has something to do with Windows not using UTF-8. That's nice, but it doesn't help me.
How do I tell wx to use the font encoding Windows 7 recognizes? Could someone be so kind as to provide me with a code example that does this? The documentation is a little too cryptic for me; I'm still at that struggling neophyte stage with this.
I wrote an article about fonts on my blog. I just tried the code and added an 18 pt font to the "sizes" list and it worked fine. Maybe you could try it on your computer and see if it works there too? If it does, then you'll want to see where your code differs from mine.
Okay, I figured out where my mistake was on this one. I was doing two things wrong:
I was misreading the error code. The error code referred to "weight" and not "size." The whole utf-8 thing really was a rabbit hole to nowhere.
I was putting things in the wrong order. Mike Driscoll's tutorial makes it clear with this example:
font = wx.Font(size, families[family], styles[style],
weights[weight])
that wx is picky about the order of attributes. It goes size, family, style, weight. I had them out of order. I think I was also using the wrong wx attributes. It seems that some tutorials will include wx.DEFAULT rather than wx.FONTFAMILY_DEFAULT. That's wickedly confusing to a new programmer. Is it really that hard to just write out the first part of the tag? Especially in a tutorial?
Here's the code that works:
if countfinal == 1
size = 18
font = wx.Font(size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.label_directions.SetFont(font)
Special thanks to Mike Driscoll for posting an answer and for writing that tutorial!
Cheers!
Related
So I am not very good with computers and have to create my first app for a project. It's going fine so far - essentially I am trying to create an app that records and saves data. Right now I'm still getting the record part down, since Xcode is having periodic issues. I am using this link for setting up the code:
http://www.techotopia.com/index.php/Recording_Audio_on_iOS_7_with_AVAudioRecorder
Unfortunately, I am running into 2 types of semantic errors, two red, two yellow. They are all in RecordModelController.m - the first is like this:
return [self.pageData indexOfObject:viewController.dataObject];
Xcode claims that Property 'dataObject' isn't found in any object or forward class in 'RecordDataViewController'. That's actually my two red errors, they just sound very similar so I paraphrased them into one. The yellow error, however, repeats itself twice on the same line of code, which is:
return [self viewControllerAtIndex:index storyboard:viewController. storyboard];
The yellow issues on these lines of code (again, repeated twice) is "Incompatible pointer types returning 'RecordDataViewController *' from a function with result type 'UIViewController *'" - I genuinely tried to look in RecordDataViewController.h and couldn't make sense of this. Like I said, bad with computers, not sure why I'm having this issue, and I know that it's probably something basic.
If anyone would be willing to help me out with how to deal with issues like this, that would be great. Thanks, and sorry for my incompetence.
The red are called errors. The yellow are called warnings. I'm going to suggest you look at a few beginning Xcode/iOS programming tutorials so you understand the basic concepts of how view controllers, arrays, etc. work in objective-c. The best place to start for someone completely new as yourself is here: http://www.raywenderlich.com/tutorials
Hope this helps!
I downloaded mathematica 9 a while ago, and when I put I try to try something like 'f[x]={{1,2}}', My screen instead reads 'f8x8 = ;;1,2??'. While typing it also switches notation as if it is displaying the wrong way.
I keep getting the following error as well: 'The stretchable character 0x5b in the Mathematica2Mono font (size 13) has a repeating piece (0x81) that is zero size.'
Does anyone know what this means or how to remedy the situation? I'm new to mathematica and am struggling to get to anything remotely familiar. I have uninstalled and reinstalled as well.
Contact Wolfram support. They provide whatever it takes to get it installed and running.
http://www.wolfram.com/support/contact/
l = find("Start_menu.png").similar(0.5).anyColor()
click(l)
The above is an excerpt from my code. "Start_menu.png" refers to an image of the Windows Start Menu. I got the following error when I executed this:
File "C:\Users\VPRAVE~1.TSI\AppData\Local\Temp\sikuli-tmp8636618870597770744.py", line 1, in
l = find("1368426219510.png").similar(0.5).anyColor().anySize()
AttributeError: 'org.sikuli.script.Match' object has no attribute 'similar'
Could some one help me out with this? And could some one tell me how to use anyColor() and anySize()?
find attempts to find something when it's called. So what your code says, in prose, is "find something that looks like 'Start_menu', then make the thing you found 0.5 similar, then make that any color"
This is wrong--you can't set the similarity threshold after the fact. Instead, call it as seen in the Sikuli docs.
Instead, say
l = find(Pattern("Start_menu.png").similar(0.5))
Here's the same code arranged vertically:
pattern = Pattern("Start_menu.png")
pattern.similar(0.5)
l = find(pattern)
The other problem is your reference to the anyColor() function, which doesn't exist. I see the code you're trying to run is from "Sikuli: Using GUI Screenshots for Search and Automation" (linked from the Sikuli docs), but this function (and the syntax used in that paper) don't exist in any extant version of Sikuli. You can see an open feature request for it on the Sikuli launchpad page.
This doesn't help you now, though. I don't know of another visual automation package that can do anyColor. If you wanted to use that feature for something, I suggest asking a new question where you describe the problem you're trying to solve, and someone may be able to suggest a work-around for that specific case.
I would like to get a current date time with erlang.
I have tried using the code below;
{{Year,Month,Day},{Hour,Min,Sec}} = erlang:localtime().
But sometimes it got an error like '** exception error: no match of right hand side value {{2012,5,6},{23,40,58}}'
Looks like there is a problem with 1 digit. I try searching couple of webs but still cannot find a way to cope this.
I believe this is quite an easy one but as a erlang newbie, I cannot resolve this. I try my best.
Env:
Erlang {"OTP APN 181 01","R15B01"} installed with windows binary version
Windows XP
Thanks in advance,
No, there is no problem with 1 digit. It should match perfectly well (check with {{Year,Month,Day},{Hour,Min,Sec}} = {{2012,5,6},{23,40,58}}). Most likely you have already assigned one of the variables to something earlier in the function.
I am writing a simple application that utilizes option(radio) buttons in vb6.
I am attempting to make different buttons and labels appear based on which optionbutton has been selected. I attempted to use an if statement that looks like this:
If (EditOpenTicketRadioButton.value = True) Then
label.visible = true
elseIf(...) then....
and on.
things start acting strange when I begin to type the period after EditOpenTicketRadioButton. the only options that intellisense gives me are Count, Item, LBound, and UBound. I know from internet examples It should be like the above example right? it will not run with that syntax it gives me an error that states: compile Error: Method or data member not found. then it points me to the Load method for my form...
If anyone can help me make sense of this it would be greatly appreciated.
Thanks in advance!
From the (very, very) limited information you gave, I can only assume EditOpenTicketRadioButton is a victim of extremely poor name choice and is actually an array of radio buttons.
If that's the case, you need to figure out which button you mean, and use it like EditOpenTicketRadioButton(0) or whatever.