let nameBox = UILabel(x: 0, y: 0, w: sideSize, h: sideSize*2/4)
nameBox.text = skillName
nameBox.textAlignment = .Center
nameBox.numberOfLines = 0
nameBox.adjustsFontSizeToFitWidth = true
nameBox.addBorderLeft(size: 1, color: UIColor.blackColor())
nameBox.addBorderTop(size: 1, color: UIColor.blackColor())
nameBox.addBorderRight(size: 1, color: UIColor.blackColor())
container.addSubview(nameBox)
This is the code I have and its output is below.
As you can see it has modified everything perfectly except for Communication & Lumberjack. Why is it, and how can I solve it?
Looks like you need to set the lineBreakMode of the label to .ByWordWrapping.
Another thought is that you really want the font to be smaller. Perhaps this is prevented by the minimumScaleFactor property.
From the docs for adjustsFontSizeToFitWidth:
The default value for this property is false. If you change it to true, you should also set an appropriate minimum font size by modifying the minimumFontSize property.
This seems to be a documentation bug. minimumFontSize is deprecated.
Related
When I use comboboxtext with a lot of options, I can see that there is no scroll. I can go up and down with the mouse, moving it or with the central button, but the typical scroll widget to move faster up and down does not appear anywhere.
How can I make the scroll widget appear in the options of the comboboxtext?
require 'gtk3'
Material2 = Gtk::ComboBoxText.new()
for i in (0..100)
string = "material " + i.to_s
Material2.append_text(string)
end
$MenuPrincipal = Gtk::Table.new(60, 60, true)
$MenuPrincipal.attach(Material2, 0, 60, 0, 10, $options, $options, 0, 0)
$window = Gtk::Window.new
$options = Gtk::AttachOptions::EXPAND | Gtk::AttachOptions::SHRINK
$window.add($MenuPrincipal)
$window.show_all
Gtk.main
Thanks in advance
You need to change (or add) line in the css style:
* {
-GtkComboBox-appears-as-list: 1;
}
If you don't have control over user's style see my answer about modifying labels' style from code (example is in python).
I have not found how to achieve it without modifying style but maybe there is some hidden gem in ruby bindings.
I'm trying to create a function to create a button (so keep the "clean" code).
Here is the code:
(
Window.closeAll;
~w = Window.new(
name: "Xylophone",
resizable: true,
border: true,
server: s,
scroll: false);
~w.alwaysOnTop = true;
/**
* Function that creates a button.
*/
createButtonFunc = {
|
l = 20, t = 20, w = 40, h = 190, // button position
nameNote = "note", // button name
freqs // frequency to play
|
Button(
parent: ~w, // the parent view
bounds: Rect(left: l, top: t, width: w, height: h)
)
.states_([[nameNote, Color.black, Color.fromHexString("#FF0000")]])
.action_({Synth("xyl", [\freqs, freqs])});
}
)
(
SynthDef("xyl", {
|
out = 0, // the index of the bus to write out to
freqs = #[410], // array of filter frequencies
rings = #[0.8] // array of 60 dB decay times in seconds for the filters
|
...
)
The error is: ERROR: Variable 'createButtonFunc' not defined.
Why?
Sorry but I'm a beginner.
Thanks!
Probably a little late to answer this, but I hope this might help someone else with the same question.
The reason you're getting that error is because you're using a variable name before you're declared it.
In other words, if you try to evaluate
variableName
on its own, you'll always get an error, because the interpreter can't match that name to anything else it knows. To solve this, you can use a global interpreter variable (a-z), an environment variable (like ~createButtonFunc), or declare var createButtonFunc earlier on in your code. Note that this last one means you won't be able to access that variable name after interpreting that chunk, which may or may not be a good thing. If you want to be able to access it later, I think it makes the most sense to write ~createButtonFunc.
By the way, you can just use w instead of ~w; single-letter variable names are global by default, and that's the idiomatic usage.
-Brian
As you can see in the pic below, only 50% of my last candle appears and I am having a hard time trying to figure out the settings which will make sure I can view the last candle in its entirety
If you look at the last candle in RED, you will see that the axis begins at midpoint of the last candle. If you compare this with below candle , you can fully view the last candle
http://jsfiddle.net/amcharts/TLx2n/
Key and relevant chart componenets are as follows:
graph = new AmCharts.StockGraph();
graph.id = "Price";
graph.title="Main";
graph.valueAxis = 'v1';
graph.showHandOnHover= true;
graph.proCandlesticks= false;
graph.labels = true;
graph.balloonColor="#00000";
graph.comparable=true;
graph.openField="Open";
graph.highField="High";
graph.closeField="Close";
graph.valueField="Close";
graph.type='candlestick';
graph.fillAlphas= 0.7;
graph.lineThickness= 1;
graph.fillColors= '#CC0000';
graph.lineColor= '#CC0000';
graph.negativeFillColors= '#000000';
graph.negativeLineColor= '#000000';
graph.negativeLineAlpha= 1;
graph.negativeFillAlphas= 0.7;
graph.proCandlesticks= false;
var categoryAxis = chart.categoryAxis;
categoryAxis.axisAlpha = 1;
categoryAxis.groupToPeriods = ["DD", "WW","MM"];
categoryAxis.maxSeries=300;
categoryAxis.fillAlpha=.2;
categoryAxis.equalSpacing = true;
categoryAxis.parseDates = true;
categoryAxis.startOnAxis = true;
categoryAxis.gridAlpha = 0.5;
categoryAxis.minorGridAlpha = 0.07;
categoryAxis.axisColor = "#000000";
categoryAxis.axisHeight=25;
categoryAxis.inside=false;
categoryAxis.tickLength = 0;
categoryAxis.gridThickness = 0;
categoryAxis.minorGridEnabled=false;
categoryAxis.axisThickness=0;
categoryAxis.gridThickness=0;
Other properties that I am using are as follows:
1. ValueAxesSettings
inside:false,
autoMargins:true,
minorGridEnabled: false,
logarithmic: false,
treatZeroAs: 0,
axisAlpha: 1,
gridAlpha: 0,
fillAlpha: 0,
minorGridAlpha : 0.07,
gridColor: "#000000",
axisThickness: 1,
gridThickness : 1,
tickLength: 1,
minMaxMultiplier: 1
Please let me know if I have not been clear in articulating the pain point in visualizing the last candle in its entirety or have not provided enough details. Please ignore any syntax error in the code as I am using a different language compiler.
The reason why the last candle is cut off is that you have startOnAxis set to true, which means exactly that - I want my last and first categories to start and end in the middle. Set it to false.
Please note that on date-based category axis, this setting will work only if equalSpacing is set to true. (disabling equalSpacing if you don't actually need it would disable cutting off of candles as well)
As a side note, looking at your code, it seems you are mixing Serial and Stock Chart config together. ValueAxesSettings is a feature of Stock Chart and would be ignored on Serial chart. The same goes for groupToPeriods, maxSeries, etc.
I recently updated to Xcode 7, beta 3.
And I've run into some issues, I can't seem to find any questions for on SO.
When I run my application, i get 3 errors:
Use of unresolved identifier 'kCGBlendModeMultiply'
Use of unresolved identifier 'kCGLineCapRound'
Use of unresolved identifier 'kCGLineJoinMiter'
However the 2 latter ones, disappear, although I assume they will show up after the first one is fixed (hence why I included it in this question).
I didn't see anything in the release notes about these being removed? So I'm a bit stuck at what to do. I tried rewriting the lines of course, but the 3 things I used don't show up as options anymore. In case that they are just gone in the latest Swift 2.0, what can I use instead?
Here's the code for the first error.
func alpha(value:CGFloat)->UIImage
{
UIGraphicsBeginImageContextWithOptions(self.size, false, 0.0)
let ctx = UIGraphicsGetCurrentContext()
let area = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)
CGContextScaleCTM(ctx, 1, -1);
CGContextTranslateCTM(ctx, 0, -area.size.height)
CGContextSetBlendMode(ctx, kCGBlendModeMultiply)
CGContextSetAlpha(ctx, value)
CGContextDrawImage(ctx, area, self.CGImage)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage;
}
Here's the code for the 2 latter errors:
for layer in [ self.top, self.middle, self.bottom ] {
layer.fillColor = nil
layer.strokeColor = UIColor.whiteColor().CGColor
layer.lineWidth = 4
layer.miterLimit = 4
layer.lineCap = kCALineCapRound
layer.masksToBounds = true
let strokingPath = CGPathCreateCopyByStrokingPath(layer.path, nil, 4, kCGLineCapRound, kCGLineJoinMiter, 4)
layer.bounds = CGPathGetPathBoundingBox(strokingPath)
layer.actions = [
"strokeStart": NSNull(),
"strokeEnd": NSNull(),
"transform": NSNull()
]
self.layer.addSublayer(layer)
}
Any help would be greatly appreciated! :)
This should work:
CGContextSetBlendMode(ctx, CGBlendMode.Multiply)
... or even just this:
CGContextSetBlendMode(ctx, .Multiply)
If you Ctrl-click on CGContextSetBlendMode and then from its declaration jump (in the same way) to declaration of CGBlendMode then you will see:
enum CGBlendMode : Int32 {
/* Available in Mac OS X 10.4 & later. */
case Normal
case Multiply
case Screen
case Overlay
// ...
}
Similarly, the other line that produces the error should be changed to:
let strokingPath = CGPathCreateCopyByStrokingPath(layer.path, nil, 4, .Round, .Miter, 4)
The idea is quite simple: I have 2 comboboxes. The second one should refreseh its values depending on the chose from the first one.
# combobox 1:
$shape = TkVariable.new
$combobox_1 = Tk::Tile::Combobox.new(parent) { textvariable $shape; values ['IPE', 'HEA']}
# combobox 2:
$size = TkVariable.new
$combobox_2 = Tk::Tile::Combobox.new(parent) { textvariable $size; values $size_list}
# action
$combobox_1.bind("<ComboboxSelected>") {
case $shape
when 'IPE' then $size_list = [80, 100, ...]
when 'HEA' then $size_list = [90, 130, ...]
end
}
But nothing happens. combobox 2 doesn't seem to realize that its values have been changed. how can I solve this problem?
This will not work, you used this variable to create the combo box, but changing it will not change the combobox.
I suppose what you are looking for is set
when 'IPE' then $combobox_2.values([80, 100, ...])