Perl TK - Wrap text in an Entry widget - word-wrap

I created a table that contains a "Key" column, "Value" column and a "New Value" column as shown in the image below.
The "Key" and "Value" columns are implemented as Labels, the "Value" column is wrapped as you can see.
The "New Value" column is implemented as an Entry widget because it should be editable. There is a Copy & Paste button that copies the value to the "New Value" Entry field.
I would like to wrap the text in the Entry widget, so after pressing the button it will look like the text in the "Value" field.
Image that shows the table I built and the difference between the wrapped Label to the text in the Entry field
Here is the piece of code that defines the shown columns:
my $key_label = $table->Label(-text => $key , -width => 50, -bg => $background_color, -anchor => 'w', -relief => $relief_style, -wraplength => 300)->pack(-side => 'left');
$table->put($curr_row,1,$key_label);
my $orig_val_label = $table->Label(-text => $full_cfg_hash{$key}{'old_value'}, -width => 50, -bg => $background_color, -anchor => 'w', -relief => $relief_style, -wraplength => 300)->pack(-side => 'left');
$table->put($curr_row,2,$orig_val_label);
my $new_val_entry = $table->Entry(-text => $full_cfg_hash{$key}{'new_value'}, -width => $entry_size, -bg => $background_color)->pack( -side => 'left', -fill => 'both', -expand => 'yes');
$table->put($curr_row,3,$new_val_entry);
my $copy_paste_btn = $table->Button(-text => "Copy & Edit\nOld Value", -command => [\&copy_n_edit_old_value,$full_cfg_hash{$key}{'old_value'},$new_val_entry], -bg => $buttons_background, -foreground => $buttons_text_color)->pack(-side => 'left', -padx => 5);
$table->put($curr_row,4,$copy_paste_btn);

The Tk::Text widget is for multi-line text entry, usually combined with Tk::Scrolled, something like:
my $new_val_entry = $table->Scrolled(
'Text',
-width => 40,
-height => 3,
-wrap => 'word',
-scrollbars => 'e',
-font => $my_font,
)->pack(
-expand => 1,
-fill => 'both',
-padx => 5,
-pady => 5,
);

Related

Xamarin UITest Query How to get just the label as response

When I query my listview with automation Id in the Repl() window I get back a chunk of data. I only want back one field 'Text' or 'Label'
here is my query:
app.Query(q => q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0))
here is the return: [ [0] {
Id => null,
Description => ">",
Rect => {
Width => 88,
Height => 20.5,
X => 12,
Y => 144,
CenterX => 56,
CenterY => 154.25
},
Label => "Abril, Jill M.",
Text => "Abril, Jill M.",
Class => "UILabel",
Enabled => true
}
]
I want to continue the query and return only "Abril, Jill M."
I tried adding .Label no luck it broke with error:
(1,103): error CS1061: Type Xamarin.UITest.Queries.AppQuery' does not contain a definition forLabel' and no extension method Label' of typeXamarin.UITest.Queries.AppQuery' could be found. Are you missing an assembly reference
This should work:
var query = app.Query(q => q.Id("officerList")
.Descendant().Id("officerName")
.Index(0).Class("UILabel")
.Index(0));
var labelText = query[0]?.Text;
labelText should contain the value of the label you want.
In resume, the Query returns an Array of AppResult (AppResult[]). You need to get the item you want which is this case is the first item.
Hope this helps.-
You can try this query also for Label -
q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0)).Label
Output - "Abril, Jill M.", ,
OR For Text
q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0)).first.text
Output - "Abril, Jill M."
May be this would work

Fill area above line in AmCharts

I'm plotting threshold violations. In some cases, thresholds are violated when the values are above the threshold. In this case, I fill the area below the line, like so:
However, in cases where values violate the threshold when they are below it, I want to fill the area above the line. Because I don't know how, the below image looks a bit weird. It'd be better if only the big dip at the beginning was in red. Like the reverse effect of the first image.
How can I fill the area above a line chart in AmCharts 3?
My current configuration (excuse the PHP, my frontend app eats JSON):
array(
'id' => 'major',
'valueAxis' => 'result',
'valueField' => 'result',
'type' => 'smoothedLine',
'lineThickness' => 2,
'lineAlpha' => 1,
'lineColor' => $threshold_at_top ? 'gold' : 'crimson',
'fillAlphas' => $threshold_at_top ? 0.001 : 0.1,
'negativeLineAlpha' => 1,
'negativeLineColor' => $threshold_at_top ? 'crimson' : 'gold',
'negativeFillAlphas' => $threshold_at_top ? 0.1 : 0.001,
'negativeBase' => $threshold_major,
'bullet' => 'none',
'balloon' => array(
'enabled' => false
)
),
array(
'id' => 'minor',
'valueAxis' => 'result',
'valueField' => 'result',
'type' => 'smoothedLine',
'lineThickness' => 2,
'lineAlpha' => $threshold_at_top ? 1 : 0,
'lineColor' => $threshold_at_top ? 'teal' : 'crimson',
'fillAlphas' => $threshold_at_top ? 0.001 : 0.1,
'negativeLineAlpha' => $threshold_at_top ? 0 : 1,
'negativeLineColor' => $threshold_at_top ? 'crimson' : 'teal',
'negativeFillAlphas' => $threshold_at_top ? 0.1 : 0.001,
'negativeBase' => $threshold_minor,
'bullet' => 'none',
'balloonText' => '<b>Result</b><br /><span style="font-size:1.5em;">[[value]]' . ( $last_datapoint->is_percentage ? ' %' : '' ) . '</span>',
'balloon' => array(
'adjustBorderColor' => false,
'color' => '#f1f1f1',
'fillColor' => '#2d87c3'
)
)
minor is the same line chart drawn on top of major.
What I've tried so far
When $threshold_at_top == true, I add another (invisible) top graph, which is simply the same value at each datapoint. This value is above all other values of the other graphs. For example, when I'm plotting a graph with results between 0 and 100, I plot this hidden top graph at 100.
Then I add it to the graphs object (as first element):
array_unshift( $options[ 'graphs' ], array(
'id' => 'top',
'valueAxis' => 'result',
'valueField' => 'top',
'type' => 'smoothedLine',
'lineAlpha' => 0,
'fillAlphas' => 0,
'bullet' => 'none',
'balloon' => array(
'enabled' => false
)
));
Then, I tell my existing major and minor graphs to 'fillToGraph' : 'top':
$options[ 'graphs' ][ 3 ][ 'fillToGraph' ] = 'top';
$options[ 'graphs' ][ 4 ][ 'fillToGraph' ] = 'top';
This gives the desired effect, but only when zoomed in enough:
When scrolling the same chart further to the right, new datapoints come into view, and it somehow messes up the area filled:
I reached out to AmCharts support, and they confirmed my suspicion (emphasis mine):
I checked with colleagues and I just wanted to let you know that
regular line graphs can support both fillToGraph and negativeFill at
the same time. You can see this behavior in the example below:
https://codepen.io/team/amcharts/pen/f8d6c8c5d3a2b4550a2b99f7486355e5?editors=0010
"graphs": [{
"id": "fromGraph",
"fillAlphas": 0.2,
"fillToGraph": "toGraph",
//"type": "smoothedLine",
"lineAlpha": 1,
"showBalloon": false,
"valueField": "fromValue",
"negativeBase": 40,
"negativeLineColor": "crimson"
}...
Therefore, we suggest using regular lines instead of smoothedLines, if
at all possible.
It's not possible to create my desired effect using smoothedLine graphs. See the bug below:

Get the ordered product size and color in order items admin grid in Magento 1.9.2

I am showing a list of items ordered from all the orders from 'sales_flat_order_item table' in Magneto 1.9.2. I get the name, SKU, and all other values from the following collection.
protected function _prepareCollection() {
$collection = Mage::getModel('sales/order_item')->getCollection();
$collection->getSelect()->join(array('o' => 'sales_flat_order'), 'main_table.order_id = o.entity_id', array('increment_id','created_at'));
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
Now I want to get the size and color of the item ordered. I am new to Magento, so I have no clue where I can get these values from.
You can access them in sales_flat_order_item table collection.
$data = $collection->getData();
$optionsData = unserialize($data['product_options']);
echo "<pre>";print_r($optionsData);
// check the [attributes_info] for the custom options
The data in product_options is serialized, so if you unserialize it you end up with something like below :
Array
(
[info_buyRequest] => Array
(
[uenc] => aHR0cDovLzUwLjU2LjIxMy4xNTcvbWVuL3RlZXMta25pdHMtYW5kLXBvbG9zL2NoZWxzZWEtdGVlLTUxNC5odG1sP29wdGlvbnM9Y2FydA,,
[product] => 409
[related_product] =>
[super_attribute] => Array
(
[92] => 20
[180] => 80
)
[qty] => 6
[return_url] =>
)
[attributes_info] => Array
(
[0] => Array
(
[label] => Color
[value] => Black
)
[1] => Array
(
[label] => Size
[value] => S
)
)
[simple_name] => Chelsea Tee
[simple_sku] => mtk004
[product_calculations] => 1
[shipment_type] => 0
[giftcard_lifetime] =>
[giftcard_is_redeemable] => 0
[giftcard_email_template] =>
[giftcard_type] =>
)

How to import address line 2 field using Magento AvS_fastsimpleimporter

How can I import a customer's address line 2 using the AvS importer for Magento? The example shows only one line and the names do not match the Magento fields, so I'm not sure how to handle this.
$data = array(
array(
'email' => 'customer#company.com',
'_website' => 'base',
'group_id' => 1,
'firstname' => 'John',
'lastname' => 'Doe',
'_address_firstname' => 'John',
'_address_lastname' => 'Doe',
'_address_street' => 'Main Street 1',
'_address_postcode' => '12345',
'_address_city' => 'Springfield',
'_address_country_id' => 'US',
'_address_telephone' => '+1 2345 6789',
'_address_default_billing_' => 1,
'_address_default_shipping_' => 0,
));
I tried adding '_address_street2', but that does not work.
You can use the \n (newline) in the _address_street field as divider between the first and second line.
...
'_address_street' => "Main Street\n1",
...
Use double quotes for this entry in the array to have the \n be parsed as newline
The result will be stored as provided in the database table customer_address_entity_text, which is in Magento terms a multiline field. For displaying it in the Magento front and backend Magento will automatically split it up by the newline and place this in separate input fields.

How to show additional option for size, brand in magento admin panel order description page

I am importing some order using programmatically but i have a problem that how to show the additional attribute like size , brand etc after product name in the "Items Ordered" help me out
i have search a lot for this but not find the appropriate answer.
http://inchoo.net/ecommerce/magento/programming-magento/programatically-create-customer-and-order-in-magento-with-full-blown-one-page-checkout-process-under-the-hood/
actually i have these information about product :
Array
(
[pr_id] => 30250
[sku_id] => 10086663
[dmn] => (blank)
[sector] => (blank)
[cat] => (blank)
[brnd] => Mimi Holliday
[supp] => Damaris Ltd
[desc] => Black lace plunge bra with silk
[clr] => Black
[size] => 32B
[st] => Shipped
[cn_cause] =>
[ret_cause] =>
[sl_amt] => 16.99
[l_s_ex_vt] => 14.46
[l_s_ex_vt_a_vh] => 14.46
[l_p_ex_vt] => 6.87
[l_cpn] => 0
[l_shp_cst] => 1.63
[mg_b_ds] => 7.59
[mg_b_ds_prct] => 0.52489626556017
[mg_a_ds] => 7.59
[mg_a_ds_prct] => 0.52489626556017
)
Here size and brand is displayed i want to show them.

Resources